Patrick Desjardins Blog
Patrick Desjardins picture from a conference

Getting 404 error after publishing with .Net4.5 from Visual Studio 2012

Posted on: 2012-09-07

After the migration to the new framework you can have the scenario where it works on your computer but not when publishing. Even publishing to the local IIS on the computer may work but not on a remote one.

The 404 page is shown without any more information. To solve this issue, I created a MVC3 web application and published. It works! I did the same with an MVC4 and it was also working.

The difference between the two projects was that the web.config file has different assemblies version in the config file.

<compilation debug="true" targetFramework="4.0">
<assemblies> 
    <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
    <add assembly="System.Web.Helpers, Version=1.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=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
    <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
</compilation> 

As you can see I have in the code above the version 1.0 for Helpers and Routing and this is problematic because the assembly I have in the project has been converted to the version 2. So two options : migrate everything with MVC4 and use the version 2 or use MVC3 with the version 1.

I hope that if you fall into this type of 404 error after migrating from Asp.Net 4 to 4.5 that you will think to check all references.