0

I have picked up a project that is currently broken and I'm trying to fix it.

The application was last working correctly as a .NET 3.5 Web Forms application with some features implemented in MVC 2.0.

The application has become broken when it was upgraded to .NET 4.0 and is running on IIS 7. The Web Forms features work fine, but the MVC 2.0 parts no longer work. Browsing to an MVC URL fails with a 404 error. It seems as if MVC does not kick in when the URL is browsed.

I've put extracts from the web.config below.

<compilation defaultLanguage="c#" debug="true">
  <assemblies>
    <add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
    <add assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>      
  </assemblies>
</compilation>

<system.webServer>
    <modules>
        <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </modules>
    <handlers>
    </handlers>
</system.webServer>

It works on the development PC (Windows 7). Why is MVC not working when deployed to IIS 7 (Win 2k8)?

John Mills
  • 10,020
  • 12
  • 74
  • 121
  • 1
    The MVC framework relies on routing to know which controller and view to load. Can you post your Global.asax file and a sample URL you are trying to reach? – Tieson T. Apr 30 '12 at 05:25

1 Answers1

1

The modules element requires the runAllManagedModulesForAllRequests to be set as described in this answer.

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
        <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </modules>
    <handlers>
    </handlers>
</system.webServer>
Community
  • 1
  • 1
John Mills
  • 10,020
  • 12
  • 74
  • 121