0

I've deployed my mvc5 web application and it runs on IIS 7.5 but the routing for beautiful url returns a 404. In my solution I have 2 areas that work well but the main routing doesn't work well.

The first routing works well but the second routing always returns 404

First route:

routes.MapRoute(
                "Default",
                "",
                new { controller = "Login", action = "Login" },
                new[] { "MySolution.Controllers" }
            );

Second route:

            routes.MapRoute(
                "Logout",
                "logout",
                new { controller = "Login", action = "Logout" },
                new[] { "MySolution.Controllers" }
            );

I tried to install all my local computer (MVC 5, IIS 7.5 , Windows 7 Pro) then that route works well.

I've also searched some articles that suggested an update hotfix for windows 2008 R2 here. When I downloaded and installed the update Windows told me that do not allow to apply this hotfix.

Community
  • 1
  • 1
nvtthang
  • 604
  • 2
  • 10
  • 27
  • 1
    If the first one works, then routing works. Messing around with patches are just going to break your system. Your problem is most likely that your second route comes AFTER your first route. You need to switch them around because your first route is the default and matches everything. – Erik Funkenbusch Mar 28 '15 at 15:02
  • Thanks Erik Funkenbusch, I switched these routes but it still doesn't work. I think the problem is IIS 7.5 because when I access the raw route /login/logout it works. – nvtthang Mar 30 '15 at 02:36
  • No, the problem is not IIS. You aren't understanding how routing works. I don't understand what you mean by "raw route" You need to provide more information than what you have, because those two routes would not route the url /login/logut. You must have some other routes which are taking precedence. Show all your routes, in their order. – Erik Funkenbusch Mar 30 '15 at 02:59
  • I found my problem and fixed. The problem is my server has installed an extension module url rewrite of php which has been set the rule (which match "logout") in the configuration module of php. I have to add runAllManagedModulesForAllRequests="true" to see this problem. Whatever asp.net request will be overwritten so that reason why my routes config didn't reach exactly controller. Thanks so much for your recommendation. I looked back to understand mvc routing. – nvtthang Mar 30 '15 at 06:09

0 Answers0