
Although ASP.NET MVC3 can be deployed on a machine running Windows Server 2003 and Internet Information Services 6 (IIS6), the practice isn’t recommended and hosting multiple MVC3 web applications can be a painful business. If you are committed to this approach though, here are some instructions to configure IIS6 so that you can deploy a MVC3 website.
The first thing to point out is that IIS6 won’t support side-by-side hosting of ASP.NET v2 and ASP.NET v4 MVC3 websites in the same application pool. This effectively means that if you already have ASP.NET v2 websites deployed on port 80 on the web server, you are going to have to use a different port to host your MVC3 websites.
Prerequisites
- .NET Framework v4 must be installed on the web server.
- ASP.NET MVC3 must be installed on the web server.
- You must make sure ASP.NET v4 is enabled under Web Service Extensions in IIS as it may be disabled by default when initially installed.
Deploying Your MVC3 Website
- Create a new application pool for use with MVC3, specifying the port number you wish to host your websites on. Hint: I usually call mine MvcPool to make it immediately recognisable.
- Right click on the newly created application pool and choose Properties from the pop-up menu.
- Select the Recycling tab and untick all the options.
- Switch to the Performance tab and change the idle timeout value to something large. I tend to use 1440 – which equates to 24 hours. This will stop your website worker thread from being recycled so regularly and will therefore improve performance considerably.
- Click OK to confirm the changes and close the Properties window.
- Create your new website in the normal way.
- Once created, right click your website and choose Properties from the pop-up menu.
- Under the ASP.NET tab of the Properties window, select ASP.NET v4 as the target runtime. It is useful to apply the changes at this point to make sure all configuration changes are picked up.
- Continuing in the Properties window, under the Home Directory tab, make sure that Execute permissions is set to scripts only and select MvcPool (or whatever you’ve called your new pool) as the application pool being used.
- Click OK to confirm the changes and close the Properties window.
If you have followed all the above steps you should be able to copy your MVC3 website to the location you specified when creating the website and all should be good.
Some guides I’ve read online include steps for checking the configuration and adding wildcard mappings but I didn’t find that was necessary.
A hint with regards to trouble-shooting: When I deployed my first MVC3 website I found it wouldn’t work. Eventually I discovered I had missing DLLs that were stopping the website from loading. I fixed this by adding the following references to my web project in Visual Studio, then re-building and re-deploying:
- Microsoft.Web.Infrastructure
- System.Web.Razor
- System.Web.WebPages.Razor
- System.Web.WebPages.Deployment
I also had to change Copy Local to True for the following references:
- System.Web.Helpers
- System.Web.MVC
- System.Web.WebPages
- Microsoft.Web.Infrastructure
- System.Web.Razor
- System.Web.WebPages.Razor
- System.Web.WebPages.Deployment