Monday, June 16, 2008

Using ASP.NET Applications with IIS 7.0

When you are working with ASP.NET, it is important to consider the managed pipeline mode you will use. IIS 7.0 supports two modes for processing requests to ASP.NET applications:



Classic pipeline mode, is the standard processing mode used with IIS 6.0. If a managed Web application runs in an application pool with classic mode, IIS processes the requests in an application pool by using separate processing pipelines for IIS and ISAPI. This means that requests for ASP.NET applications are processed in multiple stages like this:

The incoming HTTP request is received through the IIS core.

The request is processed through ISAPI.

The request is processed through ASP.NET.

The request passes back through ISAPI.

The request passes back through the IIS core where the HTTP response finally is delivered.

Integrated pipeline mode, is a dynamic processing mode that can be used with IIS 7.0. If a managed Web application runs in an application pool with integrated mode, IIS processes the requests in an application pool by using an integrated processing pipeline for IIS and ASP.NET. This means that requests for ASP.NET applications are processed directly like this:

The incoming HTTP request is received through the IIS core and ASP.NET.

The appropriate handler executes the request and delivers the HTTP response.

From an administrator perspective, applications running in classic pipeline mode can appear to be less responsive than their integrated counterparts. From an application developer perspective, classic pipeline mode has two key limitations. First, services provided by ASP.NET modules and applications are not available to non-ASP.NET requests. Second, ASP.NET modules are unable to affect certain parts of IIS request processing that occurred before and after the ASP.NET execution path.

With an integrated pipeline, all native IIS modules and managed modules can process incoming requests at any stage. This enables services provided by managed modules to be used for requests to pages created using static content, ASP.NET, PHP, and more. Direct integration makes it possible for developers to write custom authentication modules, to create modules that modify request headers before other components process the request, and more.

When working with the integrated pipeline mode, it is important to keep in mind that in this mode ASP.NET does not rely on the ISAPI or ISAPI Extension modules. Because of this, the running of an integrated ASP.NET application is not affected by the ISAPI CGI restriction list. The ISAPI CGI restriction list applies only to ISAPI and CGI applications (which includes ASP.NET classic applications). For integrated mode to work properly, you must specify handler mappings for all custom file types.

Further, many applications written for classic pipeline mode will need to be migrated to run properly in integrated pipeline mode. The good news is that the Configuration Validation module, included as a part of the server core, can automatically detect an application that requires migration and return an error message stating that the application must be migrated. You can migrate applications by using Appcmd.exe (general-purpose IIS command-line administration tool). Any migration error reported by IIS typically contains the necessary command for migrating the application. To use this command to migrate an application automatically, right-click the command-prompt icon and choose Run As Administrator. You then can migrate an application manually by running the following command at the elevated command prompt:

appcmd migrate config AppPath

where AppPath is the virtual path of the application. The virtual path contains the name of the associated Web site and application. For example, if an application named SalesApp was configured on the Default Web Site and needed to be migrated, you could do this by running the following command:

appcmd migrate config "Default Web Site/SalesApp"

When AppCmd finishes migrating the application, the application will run in both classic and integrated modes.

Real World

Although IIS notifies you initially about applications that you need to migrate, IIS will not notify you about migration problems if you subsequently change the application code so that it uses a configuration that is not compatible with integrated mode. In this case, you may find that the application doesn't run or doesn't work as expected, and you'll need to migrate the application manually from a command prompt. If you don't want to see migration error messages, modify the validation element in the application's Web.config file so that its validateIntegratedModeConfiguration attribute is set to false, such as:

*.* Source of Information : Microsoft Press Internet Information Services (IIS) 7.0 Administrator's Pocket Consultant

No comments: