ASP.NET MVC routing fails when using default.aspx/controller/action style url

旧巷老猫 提交于 2019-12-01 12:19:27

问题


I'm deploying an ASP.NET MVC site to a IIS6 webserver, so I'm using a default.aspx/{controller}/{action} style routing strategy.

However, for some reason it doesn't really work when using the default.aspx part. No matter the url, it always gets the default action (Index) on the default controller (Public).

I've been using the excellent Routing Debugger to see what's going on.

route fail http://img169.yfrog.com/img169/7532/routefail.gif

As you can see I'm requesting default.aspx/contact, which should match the 3rd route in the table. Actually ANYTHING I write after default.aspx/ matches the two last routes in the table (I understand the last one).

I'm getting this behavior on both Cassini and IIS6.

Why is this happening?


回答1:


RouteTable.Routes.RouteExistingFiles = true;

Now it works. Got the answer from here.

I think this info should have been on the asp.net/mvc site, like this page for instance.



来源:https://stackoverflow.com/questions/1470613/asp-net-mvc-routing-fails-when-using-default-aspx-controller-action-style-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!