Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Hosted-services / web-hosting

Host MVC or Web API on IIS 5.x or IIS 6.x

0.00/5 (No votes)
10 Sep 2015CPOL2 min read 13.9K  
Host MVC or Web API on IIS 5.x or IIS 6.x

Introduction

Hosting Web API in IIS 5.x is actually not that hard as it may feel when you start. First, you wouldn’t expect that there should be any challenge hosting the Web API or MVC on IIS 5.x or IIS 6.x. You will probably be thinking that it’s kind of a web application and creating a virtual directly and copying the MVC content should be enough to do the job. But it doesn’t happen that way and there’s a reason behind it.

Background

I had faced lot of problem while hosting Web API on IIS 5.1 which was installed on my Dev machine and when I tried to configure the same on Web server, it had IIS 5.2 and I required to do a lot of reading to make it happen. I've collected my learning in this article for references and probably be helpful for the audience.

Configuration

IIS 5.x or IIS 6.x are not able to handle MVC request by default as there is no application mapping that exists for servicing MVC URI. MVC URI doesn’t contain any sort of page extension like “aspx” or “php”, so given versions of IIS are not able to service the URI without page extension.

To achieve the same, you need to tell IIS to service all such URI request through .NET framework. There is a bit of difference to achieve it in IIS 5.1 and IIS 5.2 / IIS 6.0.

For IIS 5.1, launch the IIS Manager through typing “inetmgr” in Windows -> Run. Select the Virtual Directory targeted for MVC application. Right click on it and select properties.

Image 1

Snapshot 1

Click Configuration as shown below:

Image 2

Snapshot 2

Click Add:

Image 3

Snapshot 3

Provide path of latest (.NET 4 or later) aspnet_isapi.dll and enter extension as “.*” (dot asterisk). Uncheck the checkbox “Check that file exists”. Click Ok.

Image 4

Snapshot 4

You would see it coming right on the top in Application Configuration window.

Image 5

Snapshot 5

Click ok through back to IIS. Restart the IIS and you’re done.

For IIS 5.2 or IIS 6.x, a little trick needs to be done. In snapshot 4, if you try to add wildcard in extension textbox, you would see a message “”Wrong extension”. Post IIS 5.1, for wildcard, IIS has introduced a new section altogether for wildcard extension. In post 5.1 version, picture 2 will appear as below:

Image 6

Snapshot 6

Click Insert. Provide the path of aspnet_isapi.dll, uncheck the checkbox and you’re done.

Image 7

Snapshot 7

Restart IIS to take changes in effect.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)