我们有一个带有管理区域的ASP.NET MVC 3 WebApp(areaname ='admin')。
在管理区域的页面(Razor => Index.cshtml)上,我致电:
@Html.RouteLink("Preview", Resources_Blog.Route_Name_StaticPages, new { pagename = page.Slug, area = "" }, new {target = "_blank", Request.Url.Scheme})
Route在global.asax中声明如下:
routes.MapRoute(
Resources_Blog.Route_Name_StaticPages, // Routename
Resources_Blog.Route_Url_StaticPages + "/{pagename}", // URL with parameters
new { controller = "Home", action = "Page", page = UrlParameter.Optional, area = "" }, // Defaults
new[] { "My.Namespace.Controllers" }
);
资源是:
Route_Name_StaticPages = "StaticPages"
Route_Url_StaticPages = "static"
当呈现页面或应呈现页面时,我得到此异常:
System.Web.HttpException (0x80004005): Cannot use a leading .. to exit above the top directory.
at System.Web.Util.UrlPath.ReduceVirtualPath(String path)
at System.Web.Util.UrlPath.Reduce(String path)
at System.Web.HttpResponse.ApplyAppPathModifier(String virtualPath)
at System.Web.Routing.RouteCollection.NormalizeVirtualPath(RequestContext requestContext, String virtualPath)
at System.Web.Routing.RouteCollection.GetVirtualPath(RequestContext requestContext, String name, RouteValueDictionary values)
at System.Web.Mvc.RouteCollectionExtensions.GetVirtualPathForArea(RouteCollection routes, RequestContext requestContext, String name, RouteValueDictionary values, Boolean& usingAreas)
at System.Web.Mvc.UrlHelper.GenerateUrl(String routeName, String actionName, String controllerName, RouteValueDictionary routeValues, RouteCollection routeCollection, RequestContext requestContext, Boolean includeImplicitMvcValues)
at System.Web.Mvc.UrlHelper.GenerateUrl(String routeName, String actionName, String controllerName, String protocol, String hostName, String fragment, RouteValueDictionary routeValues, RouteCollection routeCollection, RequestContext requestContext, Boolean includeImplicitMvcValues)
at System.Web.Mvc.HtmlHelper.GenerateLinkInternal(RequestContext requestContext, RouteCollection routeCollection, String linkText, String routeName, String actionName, String controllerName, String protocol, String hostName, String fragment, RouteValueDictionary routeValues, IDictionary`2 htmlAttributes, Boolean includeImplicitMvcValues)
at System.Web.Mvc.Html.LinkExtensions.RouteLink(HtmlHelper htmlHelper, String linkText, String routeName, RouteValueDictionary routeValues, IDictionary`2 htmlAttributes)
不幸的是,异常仅在生命系统上抛出而不是在developystem上,所以我无法真正调试它。 它是一个IIS 7。
我也尝试调用RouteLink-methode而不使用area-parameter也会抛出异常:
Html.RouteLink("Preview", Resources_Blog.Route_Name_StaticPages, new { pagename = page.Slug, area = "" }, new {target = "_blank", Request.Url.Scheme})
另一个尝试是调用RouteUrl,但它也失败了:
<a target="_blank" href="@Url.RouteUrl(Resources_Blog.Route_Name_StaticPages, new { pagename = page.Slug })">@Resources_Administration.Pages_StaticPage_Show</a>
有人可以帮助我们吗?
是IIS配置问题还是区域错误配置?
答案 0 :(得分:0)
“解决”了这个问题。
B-Test成功注入了一个包含“\ .. \ .. \ .. \ .. \ .. \ ..”的slu .. 所以异常被正确抛出。