Wednesday, February 25, 2009

Deploy a ASP.Net MVC Application on IIS 5.1(Windows Xp)

Some of the problems encountered during deployment of an Asp.NET MVC Application are

  1. Page not found error.
  2. Only the first page opens after setting URL routing.
Here are some of the solutions I found helpful. I have used them. Hopefully they work for you :)..

I have given the detailed instructions for everyone to understand.

Basic IIS setup

  • Install the IIS
  • Install .Net framework 3.5 SP1 (Install after IIS is installed because permissions are not set properly if these steps are interchanged)
  • If IIS is installed after .Net, try resetting the Framework by
  • C:/Windows/Microsoft .Net/Framework/V2.0xxx/aspnet_regiis –i
  • Install the application or copy paste (depends on how you want to deploy)
  • Configure the IIS as follows
  1. Add the Application to the server under the default websiteRight-Click->Properties.
  2. Under the virtual directory select Configuration
  3. Under Mappings select Add
  4. Give the path of asp api in Executable i.e “C:/Windows/Microsoft .Net/Framework/V2.0xxx/aspnet_isapi.dll”
  5. Give the extension as “.*”
  6. Uncheck the “Check that file exists”
  7. If Ok button is disabled click on the text box of Executable.
  • Make changes in the application as needed so that URLs are relative to Hosting Environment(Refer below on how to modify MVC URLs for deployment).
  • Also you have to change the DataBase folder i.e. App_Data`s permission to R/W else “Cannot write to database” error occurs.
The above steps ensure that your Asp.NET MVC app runs, i.e. first problem is solved.

How to modify MVC URLs for deployment

  • Usually when we write a Asp.Net MVC app, we give the URLs as "/Home/abcd" but this wont work as "/" is not the root of project but it is the root of the application in the website deployed.
  • To solve this problem we have a URL provider for Asp.NET MVC. It takes the Controller, Action as parameters and returns a URL for navigation
example : We can rewrite the following URL "/Home/abcd" as URL.Action("abcd","Home");

This will solve the second problem :)

No comments:

Post a Comment