MVC不能使用领先的..退出顶级目录上方 [英] MVC Cannot use a leading .. to exit above the top directory

查看:172
本文介绍了MVC不能使用领先的..退出顶级目录上方的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个网站建立与ASP.NET MVC 3。

Have a Website build with ASP.NET MVC 3.

下面发布它:下创建的网站虚拟目录,复制MVC应用程序到这个文件夹,并把它转化为应用。因此,网站结构看起来像

Publish it as below: create a virtual directory under website, copy MVC application to this folder and turn it to application. So the site structure looks like

有UrlRewite下面让 http://www.xxx.com 将重写的 http://www.xxx.com/travel 没有URL改变。

Have UrlRewite as below so that http://www.xxx.com will be rewrite to http://www.xxx.com/travel without url changed.

<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>

然后我的问题就出来了。

Then My problem came out.

SCRIPT SRC =@ Url.Content (〜/内容/ JS / Index.js)TYPE =文/ JavaScript的>

script src="@Url.Content("~/Content/Js/Index.js")" type="text/javascript">

Url.RouteUrl (Lvxingshe)

Url.RouteUrl("Lvxingshe")

Url.RouteUrl (ListOfCity,新{LOCATIONNAME =LA})

Url.RouteUrl("ListOfCity", new { locationname = "LA" })

SCRIPT SRC =@ Url.Content (/内容/ JS / Index.js)TYPE =文/ JavaScript的>

script src="@Url.Content("/Content/Js/Index.js")" type="text/javascript">

我在我家/索引视图codeS以上。他们扔例外:

I have codes above in my home/index view. And they threw exceptions:

无法使用导致..退出顶级目录之上。

请帮我出

推荐答案

在我的情况下创造了航线配置额外的规则解决的问题。

In my case creating extra rule in route config solved problem.

得到这样的规则:

<rule name="site/company/CompanyId-CompanyName/" stopProcessing="true">
    <match url="^company/([0-9]+)-([^/^&amp;]+)(/{0,1})$" />
    <action type="Rewrite" url="employer/{R:1}" />
</rule>

在操作URL属性格式,你应该使用这个额外的规则。

In action url propery you should use this extra rule.

// for urlRewrite
routes.MapRoute("Employer", 
    "employer/{empid}", 
    new { controller = "Employer", action = "Index" }, 
    new { empid = @"\d+" }
);

这篇关于MVC不能使用领先的..退出顶级目录上方的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆