19

I have an mvc app developed and tested with Cassini. Deployed to my site on GoDaddy, and the default page comes up fine. Click to log in, and I get a 404.

I'm running under IIS 7 there, so this is unexpected. My routes are pretty plain:

        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            "Default",                                              
            "{controller}/{action}/{id}",                           
            new { controller = "Public", action = "Index", id = "" } 
        );
        routes.MapRoute(
            "Report1",
            "Report/{action}/{start}/{end}",
            new { controller = "Report", action = "Index" }
        );
        routes.MapRoute(
            "Report2",
            "Report/{action}/{start}/{end}/{idList}",
            new { controller = "Report", action = "Index" }
        );

Any idea what might be going on or how I can troubleshoot this?

4 Answers 4

31

Are you running in IIS7 integrated mode?

Classic mode of IIS7 does not automatically map extensionless URLs to ASP.NET (much like IIS6).

Also make sure your Web.config <system.webServer> tag is configured correctly.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, Mehrdad. Turns out that GoDaddy defaults IIS 7 to classic mode.
<system.webServer> <modules runAllManagedModulesForAllRequests="true"/> </system.webServer>
24

Don't use runAllManagedModulesForAllRequests. You want to let IIS handle resources such as images.

<system.webServer> <!-- Rather do NOT use this -->
  <modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>

Instead add the MVC routing module

<system.webServer>
  <modules>
    <remove name="UrlRoutingModule-4.0" />
    <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />
  </modules>
</system.webServer>

4 Comments

This answer also worked and does appear to have a more efficient (and elegant) approach.
This method worked well for me in an ASP.NET Web API application. The app worked fined locally, but when deployed to any other environment, I just received a 404 for any Web API request. Added the routing module bits noted above and everything is fine. Similar issue here: stackoverflow.com/questions/15389855/…. Thanks!
I was pulling my hair out trying to get an MVC app to accept HTTP DELETE requests. This took care of it for me. Thanks!
same problem, the method delete request don't work if i deploy to other environment: iis 8 ok but in other environment (iis 7) i get 404
14

Tried everything, I had to set my web config like this, to make it work.

 <system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

1 Comment

Wow this actually worked! But why do I have the feeling it will come back to haunt me?
1

I had the same problem, I uploaded the controller, web.config and other classes but I forgot to upload the bin folder.

After I uploaded the bin folder, it worked!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.