routing to blank request in mvc asp.net using IIS 6.0

人盡茶涼 提交于 2019-12-24 19:17:33

问题


I'm attempting to connect to my published website using the following url. http://www.mywebsite.com/ I keep getting: The incoming request does not match any route. Here are my routing rules:

routes.MapRoute(
                "Default",                                              // Route name
                "{controller}.aspx/{action}/{id}",                           // URL with parameters
                new { controller = "Home", action = "Index", id = "" }  // Parameter defaults
            );

            routes.MapRoute(
                "Default2",                                              // Route name
                "/",                           // URL with parameters
                new { controller = "Home", action = "Index", id = "" }  // Parameter defaults
            );

I'm using authentication as such:

<authentication mode="Forms" >
            <forms loginUrl="~/Home.aspx/Index"
                    protection="All"
                    timeout="300"/>
        </authentication>

When I'm not authenticated it goes to the correct page, but when I am authenticated it throws the above error. I'm using IIS 6.0 and doing the whole rewriting url workaround option.

What am I missing?


回答1:


Change "/" in "Default2" route to "":

routes.MapRoute("Default2", "", new { ... });

Also make sure you have followed this guide: http://haacked.com/archive/2008/11/26/asp.net-mvc-on-iis-6-walkthrough.aspx for Default.aspx file if you are on IIS6.



来源:https://stackoverflow.com/questions/659465/routing-to-blank-request-in-mvc-asp-net-using-iis-6-0

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