How to Understand the managed pipeline mode of the two application pool in IIS 7)

Source: Internet
Author: User
Tags microsoft iis visual studio 2010
How to Understand the managed pipeline mode of the two application pool in IIS 7)

Some netizens asked a related question: how to understand applications in IIS 7ProgramPipeline mode of the pool, especially how to understand the "integrated mode". I will write another article todayArticleTo introduce this problem.

 

IIS 7 is the latest version of Microsoft IIS, which is available from Vista and is currently available in Vista, Windows 7, and Windows Server 2008. One of the highlights of this new version is that it provides two pipeline modes to support different application scenarios.

 

The pipeline mode mentioned here refers to an attribute of the application pool.

The two pipeline modes are integrated and classic)

So how do we understand these two models?

Classic Mode:This is a mode that is compatible with IIS 6 or earlier versions. A typical problem is that ASP is being processed. net, it works as a plug-in through a so-called ISAPI program. Different isapis are required for different dynamic applications (such as ASP and PHP.

For example, the following is an ISAPI ing of the registration number.

We can see that different ISAPI programs are specified for different requests. This is a graphical description of the pipeline.

 

Integrated Mode: This new mode allows us to change ASP. net is better integrated with IIS, and even allows us. net write some functions (such as module) to change IIS behavior (Extension ). The advantage of integration is that it does not use ISAPI to improve speed and stability. As for expansion, we can have more control over IIS and other types of requests. (For example, we want static web pages to have some special behaviors)

This is explained.

The above two pictures are from the following article, and this article provides more detailed theoretical introduction.

Http://learn.iis.net/page.aspx/243/aspnet-integration-with-iis-7/

 

Next, I will use an example to help you better understand the integrated model.

In this example, I have a special requirement that I want to monitor the logs of all requests on the website, whether it is a dynamic webpage or a static webpage.

 

1. Create a web application

 

2. Add an httpmodule

To monitor user requests, we usually write an httpmodule

I implemented simple functions for this module (print the user's request address on the page)

 Using System; Using System. Web;Namespace Webapplication2 { Public   Class Mymodule1: ihttpmodule { /// <Summary>          /// You will need to configure this module in the web. config file of your          /// Web and register it with IIS before being able to use it. For more information          // See the following link: http://go.microsoft.com /? Linkid = 8101007          /// </Summary>          # Region Ihttpmodule members Public   Void Dispose (){ // Clean-up code here. } Public   Void Init (httpapplication context ){ // Below is an example of how you can handle logrequest event and provide              // Custom logging implementation for it Context. logrequest + = New Eventhandler (onlogrequest );} # Endregion          Public   Void Onlogrequest (Object source, eventargs e ){ // Custom logging logic can go here VaR APP = (httpapplication) source; app. response. Write (App. Request. url. tostring ());}}}

 

3. Register this module

The module must be registered before it can be used. We generally think of previous practices.

    system. web       Compilation   debug   = "true"   targetframework   = "4.0"  />     httpmodules  >    Add   name  =" test "  type   =" webapplication2.mymodule1, webapplication2 " />     httpmodules       system. web    

However, an error will occur when registering in this way.

This error indicates that the logrequest operation must run in integration mode.

So how do I register a module as an integration model?

We need to modify the configuration file to the following:

 <?  XML  Version  = "1.0" ? >  <! --  For more information on how to configure your ASP. NET application, please visit  Http://go.microsoft.com/fwlink? Linkid = 169433  -->  <  Configuration  >    <  System. Web  >      <  Compilation   Debug  = "True"   Targetframework = "4.0"   />      <! -- <Httpmodules>  <Add name = "test" type = "webapplication2.mymodule1, webapplication2"/>  </Httpmodules> -->    </  System. Web  >    <  System. Webserver  >      <  Modules  >        <  Add   Name  = "Test"   Type = "Webapplication2.mymodule1, webapplication2"  />      </  Modules  >    </  System. Webserver  >  </  Configuration  > 

Please note that there is now an additional system. webserver section, which contains a modules section. You can configure some httpmodules to be registered.

Because it is a module registered as system. Webserver, debugging in Visual Studio is ineffective.

We need to publish the application to IIS and set it to integrated mode.

 

4. Publish to IIS

There are many ways to publish. I recommend using deploy package.

Please note that the application pool we use is integrated mode

 

After the release, we will browse the home page in the browser, and we will find a special output at the bottom, that is, the address information of our current request. This indicates that our module is already working.

 

 

5. Test the module's support for static pages.

If this is the case above, we don't seem to see the advantages of this model. Can we achieve this in the past?

Please note that the previous httpmodule can only affect dynamic web pages, such as our aspx web pages, static web pages (such as HTML), or other types of dynamic web pages (such as PHP) is powerless.

So what is the current situation in this mode?

We can add a simple HTML page to the root directory of the website.

Then, we will request this page

Is it amazing? Although it is a static webpage, because our module is registered in IIS, it changes the behavior of IIS, so it still inserts a piece of output at the bottom of the page.

 

6. Summary

I hope the example above will help you better understand the integrated mode. It allows usCodeInsert it to the IIS kernel, instead of using ISAPI. This will bring about better performance and scalability.

Category: Microsoft. NET, Visual Studio 2010 &. NET Framework 4.0

Some netizens asked a related question: how to understand the pipeline mode of the application pool in IIS 7, especially how to understand the "managed mode )", I wrote another article to introduce this question.

 

IIS 7 is the latest version of Microsoft IIS, which is available from Vista and is currently available in Vista, Windows 7, and Windows Server 2008. One of the highlights of this new version is that it provides two pipeline modes to support different application scenarios.

 

The pipeline mode mentioned here refers to an attribute of the application pool.

The two pipeline modes are integrated and classic)

So how do we understand these two models?

Classic Mode:This is a mode that is compatible with IIS 6 or earlier versions. A typical problem is that ASP is being processed. net, it works as a plug-in through a so-called ISAPI program. Different isapis are required for different dynamic applications (such as ASP and PHP.

For example, the following is an ISAPI ing of the registration number.

We can see that different ISAPI programs are specified for different requests. This is a graphical description of the pipeline.

 

Integrated Mode: This new mode allows us to change ASP. net is better integrated with IIS, and even allows us. net write some functions (such as module) to change IIS behavior (Extension ). The advantage of integration is that it does not use ISAPI to improve speed and stability. As for expansion, we can have more control over IIS and other types of requests. (For example, we want static web pages to have some special behaviors)

This is explained.

The above two pictures are from the following article, and this article provides more detailed theoretical introduction.

Http://learn.iis.net/page.aspx/243/aspnet-integration-with-iis-7/

 

Next, I will use an example to help you better understand the integrated model.

In this example, I have a special requirement that I want to monitor the logs of all requests on the website, whether it is a dynamic webpage or a static webpage.

 

1. Create a web application

 

2. Add an httpmodule

To monitor user requests, we usually write an httpmodule

I implemented simple functions for this module (print the user's request address on the page)

Using System; Using System. Web; Namespace Webapplication2 { Public   Class Mymodule1: ihttpmodule { /// <Summary>          /// You will need to configure this module in the web. config file of your          /// Web and register it with IIS before being able to use it. For more information          // See the following link: http://go.microsoft.com /? Linkid = 8101007          /// </Summary>          # Region Ihttpmodule members Public  Void Dispose (){ // Clean-up code here. } Public   Void Init (httpapplication context ){ // Below is an example of how you can handle logrequest event and provide              // Custom logging implementation for it Context. logrequest + = New Eventhandler (onlogrequest );} # Endregion          Public   Void Onlogrequest (Object source, eventargs e ){ // Custom logging logic can go here VaR APP = (httpapplication) source; app. response. Write (App. Request. url. tostring ());}}}

 

3. Register this module

The module must be registered before it can be used. We generally think of previous practices.

    system. web       Compilation   debug   = "true"   targetframework   = "4.0"  />     httpmodules  >    Add   name  =" test "  type   =" webapplication2.mymodule1, webapplication2 " />     httpmodules       system. web    

However, an error will occur when registering in this way.

This error indicates that the logrequest operation must run in integration mode.

So how do I register a module as an integration model?

We need to modify the configuration file to the following:

 <?  XML  Version  = "1.0" ? >  <! --  For more information on how to configure your ASP. NET application, please visit  Http://go.microsoft.com/fwlink? Linkid = 169433  -->  <  Configuration  >    <  System. Web  >      <  Compilation   Debug  = "True"   Targetframework = "4.0"   />      <! -- <Httpmodules>  <Add name = "test" type = "webapplication2.mymodule1, webapplication2"/>  </Httpmodules> -->    </  System. Web  >    <  System. Webserver  >      <  Modules  >        <  Add   Name  = "Test"   Type = "Webapplication2.mymodule1, webapplication2"  />      </  Modules  >    </  System. Webserver  >  </  Configuration  > 

Please note that there is now an additional system. webserver section, which contains a modules section. You can configure some httpmodules to be registered.

Because it is a module registered as system. Webserver, debugging in Visual Studio is ineffective.

We need to publish the application to IIS and set it to integrated mode.

 

4. Publish to IIS

There are many ways to publish. I recommend using deploy package.

Please note that the application pool we use is integrated mode

 

After the release, we will browse the home page in the browser, and we will find a special output at the bottom, that is, the address information of our current request. This indicates that our module is already working.

 

 

5. Test the module's support for static pages.

If this is the case above, we don't seem to see the advantages of this model. Can we achieve this in the past?

Please note that the previous httpmodule can only affect dynamic web pages, such as our aspx web pages, static web pages (such as HTML), or other types of dynamic web pages (such as PHP) is powerless.

So what is the current situation in this mode?

We can add a simple HTML page to the root directory of the website.

Then, we will request this page

Is it amazing? Although it is a static webpage, because our module is registered in IIS, it changes the behavior of IIS, so it still inserts a piece of output at the bottom of the page.

 

6. Summary

I hope the example above will help you better understand the integrated mode. It allows us to insert code into the IIS kernel, instead of using ISAPI. This will bring about better performance and scalability.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.