Hosting an MVC Application on XP (IIS 5.1)

by Matt 22. March 2010 00:40

Getting an MVC 2.0 application running on my XP Pro box under IIS 5.1 was a fairly painless process, contrary to the feelings conveyed in many blog posts I had read on the subject.  Some had written they had to change their routes in their Global.asax file, and had to change links between views in their codefiles.  I don't know why this was an issue for them, because it certainly wasn't necessary for me.

However, I did get to exploit a bug in IIS 5.1 to allow MVC url rewriting :)

I personally set up the application as my Default Web Site, but you may choose a virtual directory if you would so rather. 

  1. Right click on Default Web Site and click Properties
  2. Make sure the website or virtual directory is an Application.
  3. Set permissions to Scripts Only
  4. Click Configuration.  Under the Mappings tab, click the Add button
  5. You need to insert the path to the file aspnet_isapi.dll.  This is most likely C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll.
  6. In the Extension field, enter “.*” (excluding quotes). 
  7. Select All Verbs.  Select “Script Engine”.  Make sure ”Check that file exists” is not selected.
  8. Here’s the bug.  “.*” This isn’t a valid extension in IIS 5.1 so the OK button is disabled.  Click in the Extension field, then in the Executable field, and the OK button should be enabled!  Click OK at this point.

Your website should now be able to work!

My reason for setting this up was to launch a beta testing of an application I have written.  I wanted to host it at home to save on costs and ended up using a service called No-IP to provide a Dynamic DNS.  This free service allows users to navigate to a URL that is constantly being updated with my proper IP address.  Some configuration and port forwarding settings later and I was easily able to have my url navigate to my application.

One problem I did have was an inability to log into the website I was testing – My website was swallowing some error and simply displaying “We’re sorry, your request could not be processed”.  Sure, I could have looked at my Log4Net configuration, but what fun would that be?  (Actually, I forgot I was logging.)  I simply attached to the aspnet_wp.exe worker process to debug my application as I was accessing it through the URL I had just set up.  I quickly found out that my database (sqlite in this case) was read only. 

Ultimately what I had to do was give the IUSR_MachineName account permissions to write to the file and folder in  which it resides.

  1. Right click on My Computer and select Manage.
  2. Expand System Tools
  3. Expand Local Users and Groups
  4. Select Users
  5. Find the IUSR_MachineName account.  right click - Properties
  6. Click the Member Of Tab.

I added this account to the Administrators group.  This may be too unrestricted for you, but it wasn’t an issue for me.

And voila!  Navigating to my no-ip.org subdomain url from anywhere in the world will direct the user to the application running on my desktop at home.

Tags:
Categories: IIS | MVC