这适用于ASP.NET MVC3 Web应用程序。 在RegisterRoutes中,我有以下作为我唯一的一行:
routes.MapRoute("Default", "Configuration", new { controller = "DeviceConfiguration", action = "Index" });当我运行项目时,转到URL / Configuration /会给我一个404错误。 但是,如果我将配置一词更改为任何其他单词,例如:
routes.MapRoute("Default", "Configuratio", new { controller = "DeviceConfiguration", action = "Index" });然后转到URL / Configuratio /加载就好了。 好像ASP.NET只是拒绝路由到URL / Configuration /。
同样,这是RegisterRoutes中唯一的一行; 我已经尝试评论其他一切来调试这个。 我在其他地方的代码中没有MapRoute或IgnoreRoute调用,而且我没有在任何位置编辑路由表。
我该如何改变这种行为?
This is for an ASP.NET MVC3 web application. In RegisterRoutes I have the following as my only line:
routes.MapRoute("Default", "Configuration", new { controller = "DeviceConfiguration", action = "Index" });When I run the project, going to the URL /Configuration/ gives me a 404 error. However if I change the word Configuration to any other word, such as:
routes.MapRoute("Default", "Configuratio", new { controller = "DeviceConfiguration", action = "Index" });Then going to the URL /Configuratio/ loads just fine. It seems as if ASP.NET is simply refusing to route to the URL /Configuration/.
Again, this is the only line in RegisterRoutes; I've tried commenting out everything else to debug this. I have no MapRoute or IgnoreRoute calls in my code anywhere else, and I am not editing the routing table in any location.
How can I change this behavior?
最满意答案
我怀疑您在应用程序的根目录下有一个名为Configuration的物理文件夹。 ASP.NET MVC路由引擎优先选择路由上的物理文件夹。 一种可能的方法是在路由定义后将 RouteExistingFiles属性设置为true:
routes.MapRoute( "Default", "Configuration", new { controller = "DeviceConfiguration", action = "Index" }); routes.RouteExistingFiles = true;I suspect that you have a physical folder called Configuration under the root of your application. The ASP.NET MVC routing engine has preference for physical folders over routes. One possible way is to set the RouteExistingFiles property to true after your route definition:
routes.MapRoute( "Default", "Configuration", new { controller = "DeviceConfiguration", action = "Index" }); routes.RouteExistingFiles = true;更多推荐
Configuration,URL,MapRoute,NET,电脑培训,计算机培训,IT培训"/> <meta name=&quo
发布评论