So whats it all about?
Having been subjected to the previous n-tier, highly coupled, impossible to maintain architecture that makes up one of our software applications for far too long, a development decision was made to move into the MVC arena. However having done all the hard work of integrating the MVC framework into an existing ASP.NET Forms application (which was actually very straightforward), what worked fine in the Visual Studio IDE, failed miserably when I published to IIS.
So if like me you had an existing Web Forms application into which you have integrated the new MVC 2.0 framework and are about to publish to IIS (I’m using IIS 7.5) then this handy little checklist may be of help. Or if you have already published and are sitting looking at the following IIS error then this post will definately be of help;
1. Make sure you Routing is set up correctly
Firstly, assuming your MVC application is running correctly in the IDE, its worth double checking the Routing is configured correctly prior to deployment else you will more than likely end up with the dreaded 404 page not found error.
Your Routing rules should be registered in the Global.asax.cs file within the RegisterRoutes method or the Application_start method
2. web.config alterations
Now if you used the template provided by Visual Studio to create your MVC application then chances are your web.config file will contain everything you need, however if like me you are adding MVC to an existing Web Forms application then there are a few bits you need to consider:
Firstly this is the one that caught me out
you will need to add this binding information to ensure you are using the correct MVC 2.0 assembly. Also add the following runAllManagedModulesForAllRequests attribute to the modules section and set to True. Additionally ensure the Modules section points to the correct UrlRoutingModule assembly (version 126.96.36.199 or 188.8.131.52 depending on your framework)
Note: (If you have you application running through the IDE then chances are that the next few points regarding the web.config are already in place)
Now if your using Framework 4 then Microsoft have made things a little easier, reasons being that the Web.config was cleaned up for the ASP.NET 4.0 release and you only have to add assembly references for:
If however you are using Framework 3.5 you will need to ensure you have references to the following extra assemblies:
Also ensure that you have the following namespaces defined in the web.config