2
我有一个很奇怪的路由问题。ASP.NET MVC 3区域路由问题
我有一个ASP.NET MVC 3网站使用区域。 我在资产方面:以下路线设置:
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
但是,当我要求这个网址我得到一个“404 - 资源可以” t被发现“错误
http://site.com/Assets/Gallery/GetByCode/PRN
http://site.com/Assets/Gallery/GetByCode/prn
我试过的每一个其他的网址 - 它似乎只是PRN有问题。
我已经在GalleriesController> GetByCode动作的开始放置了一个断点,并且PRN路径甚至不尝试输入动作(如404错误所示)。
有没有人有任何想法为什么PRN不在路线中工作?还有什么我可以尝试去调查?
感谢您的帮助 Saan
做你的'Index'行动受到打击呢? – simonlchilds
否 - 索引不会受到影响 – Saan
您是否尝试去除路由上的正则表达式约束?你有没有试过把参数放在默认路由中的顺序? – simonlchilds