We are developing a web site for one of our customers using ASP.NET MVC. MVC framework is awesome, it provides a very clean architecture for separating UI, business logic & data .
For the past 2 weeks I was developing the prototype using Visual Studio 2008 and today the prototype is deployed on one of our IIS 6 Serves running on Window 2003 OS.
When I fired up the browser and accessed the prototype, the home page rendered pretty well. But the rest of the pages are broken – raising 404 errors. Boom!! The prototype is running very well when deployed on IIS 7 or Visual Studio built in web server but not on IIS 6.
Fixing the issue
The cause for the issue is identified as missing configurations in IIS 6 for running MVC and it is fixed by following these simple
1. Open IIS 6 Administrative Console and select the virtual folder of the deployed MVC application
2. Right click on the virtual folder and select Properties; it brings up properties dialog.
3. Make sure you’re on the Virtual Directory tab and select Configuration; it brings up the Application Configuration dialog
4.In the Wildcard application maps section, click the Insert. button; it brings up the wildcard application mapping dialog.
5. Enter the path as “c:\windows\microsoft.net\framework\v2.0.50727\aspnet_isapi.dll”.
Note: The path of the dll might differ on your machine. One easy way to find out is to look for the .aspx extension in the application extensions list and double click it to get the full path.
6.Uncheck the Verify that file exists checkbox and click the Ok button. Don’t forget to uncheck.
7. Save the changes by clicking on Ok.
8. That’s all. Now the 404 error should disappear.
Side effects
This is a very simple way to fix 404 errors and enable pretty URLs of MVC on IIS 6. But there is a side affect on the performance of the website. By configuring the wild card mapping, we are instructing the web sites to route all the file requests through aspnet_isapi. So even the css, js, jpg, png, etc files will be handled by aspnet_isapi and that will have a considerable impact on the performance of the server.
Is there any better way to fix the issue?
Of course there should be a better way to fix the issue, but I don’t know what is that :) This quick and dirty fix helped me to temporarily set up the prototype site on IIS 6. I’ll research more on this in the coming days and fix the issue in a better way. I’ll share the information with you .
Happy coding!!
Pingback: Exchange server mail account in Outlook configuration « windowsquery
Actually, the extension in the URL may not be as bad as it appears. Although you don’t want to destroy the purity of your URLs with a .mvc extension you can use pretty much use any extension you like (so long as you have the ability to add IIS application extension mappings). For example: for a rest service you could use the services extension:
/{controller}.services/{action}/… etc
or create an extension for each logical domain in you business model. For example:
/{controller}.shopping/{action}/… etc
/{controller}.memberarea/{action}/… etc
This is not ideal since complete freedom of your URL is the whole point but still, it is not as bad as I initially thought.
What is the extension to be added? Is that “.*” (without quotes) extension?
Thank you man!
Great, solved and helped me a lot. And also was a blessing for the server adminstrator I was about to shoot ;)
Will be sure to link to you shortly
To fix it without routing through ASP.NET you can add an extension to your controllers: site.com/Controller.mvc/Action/Id and then associate the .mvc extension with ASP.NET. You will also need to update your routes. It sucks but it is better than crapy performance (for me anyway)
Andrew,
What you suggested works fine as long as we are ready to give up the pretty URLs. One of the best thing I love in MVC is the pretty URLs feature. But on IIS6 seems to be we get pretty URLs feature at the expense of performance.