Pages

Thursday, December 24, 2009

Running ASP.NET 2.0 under IIS 7.0



In this post, I will share my experience of running ASP.NET 2.0 applications under IIS 7.0. If you run an ASP.NET 2.0 application under IIS 7.0, you will get a 500 – Internal Server Error. This will occur since IIS 7.0 has got a new enhanced architecture.

In earlier versions of IIS (6.0 and below), asp.net applications run under IIS through ISAPI extensions. These extensions have their own processing model and every request must go through this model (or pipeline). In addition to this pipeline, an asp.net application has its own request pipeline (handlers) which processes user requests. This results in two pipelines being exposed. One for ISAPI extensions and other for managed applications.

IIS 7.0 merges the two pipelines into one Integrated Managed Pipeline which handles both native and managed request. This provides added features to the developers. For example, many of .NET features such as Authentication, Authorization can be applied to images, scripts and other files which may come under ISAPI extensions. Similarly, URL Rewriting is powerful feature added to IIS 7.0 to help write SEO URLs.

Due to the above mentioned architecture, asp.net 2.0 applications do not run under IIS 7.0 out of the box. IIS will give a 500 – Internal Server Error when trying to browse the application. The solution to fix this problem is described in the following sections.


Change settings in web.config file

In this solution, we have to change a few settings in the web.config file. This is done by doing the following steps:

• Move entries in <system.web>/<httpModules> to <system.webServer>/<modules>
• Move entries in <system.web>/<httpHandlers> to <system.webServer>/<handlers>

In addition to this, also add the following entry under the <system.web> section:

<system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
</system.webServer>


Change Application Pools setting in IIS

This solution is easier to follow however; this applies to all applications running under IIS and hence prevents from taking advantages of the new IIS features. In this case changes are made in IIS Manager by the following steps:

Start IIS Manager and select ‘Applications Pool’.



In the top right corner, click on ‘Set Application Pool Defaults’. This will display the Application Pool Defaults dialog.



For the ‘Managed Pipeline Mode’ property, select ‘Classic’ and close the dialog.



Now when you browse your asp.net 2.0 application, you must be able to run it successfully. Stay tuned for more.

No comments:

Post a Comment