I have multiple websites hosted on the same server with structure as follows:
http://primary-domain.com/hostedsites/MVCWebApplication1/ = http://MVCWebApplication1.com/
http://primary-domain.com/hostedsites/MVCWebApplication2/ = http://MVCWebApplication2.com/
...
The problem is, all ~/
references made in a hosted site (ie MVCWebApplication1, MVCWebApplication2, etc) resolve to
http://MVCWebApplication1.com/hostedsites/MVCWebApplication1/
and not
Please note:
I already have the following my web.config:
<rule name="Remove Virtual Directory">
<match url=".*" />
<action type="Rewrite" url="{R:0}" />
</rule>
How can I fix this?
What I ended up doing was using a bunch of work arounds:
In web.config
:
<rewrite>
<rules>
<rule name="Remove Virtual Directory">
<match url=".*" />
<action type="Rewrite" url="{R:0}" />
</rule>
</rules>
</rewrite>
And instead of creating links like this:
<a href="~/Help">Help</a>
doing this:
@Html.ActionLink("Help", "Help") // This seems to create clean urls
您只需要将虚拟目录转换为IIS中的应用程序。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.