对于包含“PRN”的任何URL,MVC3 404
我遇到了一个奇怪的问题,任何包含“PRN”的 URL 都会返回 404。
如果我有 2 种方法:
public string Test(string x)
{
return "hello";
}
public string PRN(string x)
{
return "worked";
}
我可以通过导航到以下位置来调用测试: 控制器/测试
它将始终返回“hello”。但是,如果我尝试致电: Controller/Test/PRN,我收到 404
如果我尝试调用 Controller/PRN/Anything,我收到 404
在多个 MVC3 应用程序中,我发现任何包含“PRN”的 URL 都会返回 404 错误。有人有什么想法吗?
编辑: 这是我的路线配置:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
谢谢。
I have run into a strange issue where any URL containing "PRN" will return a 404.
If I have 2 methods:
public string Test(string x)
{
return "hello";
}
public string PRN(string x)
{
return "worked";
}
I can call test by navigating to:
Controller/Test
It will always return "hello." However, if I try to call:
Controller/Test/PRN, I get a 404
If I attempt to call Controller/PRN/Anything, I get a 404
In multiple MVC3 applications, I have found that any URL containing "PRN" will return a 404 error. Does anyone have any ideas?
EDIT:
This is my route configuration:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该阅读以下内容: http://bitquabit.com /post/zombie-operating-systems-and-aspnet-mvc/
指向:Windows 中的 ASP.NET MVC 路由与保留文件名
You should have a read a this : http://bitquabit.com/post/zombie-operating-systems-and-aspnet-mvc/
Which points to : ASP.NET MVC Routing vs. Reserved Filenames in Windows
如果您调用
Controller/Test/PRN' 它不会指向任何内容,因为您正在调用
Test` ActionMethod 并将 PRN 作为参数传递。尝试将 ...
... 添加到 Global.asax.cs 文件夹中的
RegisterRoutes
方法的顶部。If you call
Controller/Test/PRN' It wont point to anything because you are calling the
Test` ActionMethod and passing PRN as the parameter.Try adding ...
... to the top of your
RegisterRoutes
method in Global.asax.cs folder.