Asp.net mvc 3 ASP.NET MVC 3区域中的路由问题
我有一个非常奇怪的路由问题 我有一个ASP.NETMVC3网站使用区域。 我在“资源”区域中设置了以下路线:Asp.net mvc 3 ASP.NET MVC 3区域中的路由问题,asp.net-mvc-3,routing,asp.net-mvc-routing,asp.net-mvc-3-areas,Asp.net Mvc 3,Routing,Asp.net Mvc Routing,Asp.net Mvc 3 Areas,我有一个非常奇怪的路由问题 我有一个ASP.NETMVC3网站使用区域。 我在“资源”区域中设置了以下路线: public override void RegisterArea(AreaRegistrationContext context) { context.MapRoute( null, "Assets/{controller}/{action}/{code}", null, new { code = @"(\w{2,
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
null,
"Assets/{controller}/{action}/{code}",
null,
new { code = @"(\w{2,3}$)" }
);
context.MapRoute(
"Assets_default",
"Assets/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional }
);
}
当我请求以下URL时,它可以完美地工作
http://site.com/Assets/Gallery/GetByCode/AEP
http://site.com/Assets/Gallery/GetByCode/MEC
http://site.com/Assets/Gallery/GetByCode/GP
http://site.com/Assets/Gallery/GetByCode/BR2
http://site.com/Assets/Gallery/GetByCode/ZZZ
http://site.com/Assets/Gallery/GetByCode/123
但是当我请求这个URL时,我得到一个“404-找不到资源”错误
我尝试过的每一个其他URL都有效——似乎只有PRN有问题
我在GalleriesController>GetByCode操作的开始处设置了一个断点,PRN路由甚至没有尝试进入该操作(正如404错误所示)
有人知道为什么PRN在路线上不起作用吗?或者我还可以尝试调查什么
谢谢你的帮助
Saan这可能与您无法在Windows文件系统上创建文件夹“prn”有关。我的猜测是IIS使用windows文件系统的方式与上述问题产生了共鸣
事实上,这篇文章可能会帮助你:你的
索引
动作会被击中吗?你有没有试过移除路线上的正则表达式限制?您是否也尝试过将参数按默认路由中的相同顺序放置?是的,尝试过硬编码context.MapRoute约束(null,“Assets/Gallery/GetByCode/PRN”,new{controller=“Gallery”,action=“GetByCode”,code=“PRN”);但仍然不起作用哇。这很奇怪。不知道那里发生了什么!抱歉!
http://site.com/Assets/Gallery/GetByCode/PRN
http://site.com/Assets/Gallery/GetByCode/prn