【发布时间】:2013-12-20 08:22:52
【问题描述】:
使用 ASP.NET MVC 3 构建网站。
发布如下:在网站下创建一个虚拟目录,将MVC应用程序复制到该文件夹并转为应用程序。所以网站结构看起来像
具有如下 UrlRewite,以便 http://www.example.com 将被重写为 http://www.example.com/travel 而不会更改 url。
<rule name="rewrite rule for home page" enabled="true" stopProcessing="false">
<match url="^$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="/home/index" appendQueryString="false" />
</rule>
<rule name="rewrite rule for virtual path" enabled="true">
<match url="^[\w-/\.]+$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="/travel/{R:0}" appendQueryString="false" />
</rule>
然后我的问题就出来了。
script src="@Url.Content("~/Content/Js/Index.js")" type="text/javascript">
Url.RouteUrl("旅星社")
Url.RouteUrl("ListOfCity", new { locationname = "LA" })
script src="@Url.Content("/Content/Js/Index.js")" type="text/javascript">
我的主页/索引视图中有上面的代码。他们抛出了异常:
不能使用前导 .. 退出顶级目录。
【问题讨论】:
标签: asp.net-mvc-3 url-rewriting url-routing