Monday, 28 December 2009

IIS 7 – Managed pipeline mode – Global.asax redirect not working

I installed Windows 7 and I really like it. I migrated all my applications from my old machine to new. And my old machine is running WS 2003 [iis 6] and new machine is Windows 7 [IIS 7]. In all applications everything ran successful except one. I implemented exception handling in my application. I have Global.asax page and in the Application_Error event, I log the exception details and redirecting the user to the error page. Whenever there is an exception in my application the page never redirect to the error page, it stays there in the same page with exception details on the screen.

The same code ran very successful on my old server and in Windows 7 it's not. I just started thinking what could be the issue. The analysis went in this way. Code not changed, DB not changed and the only part changed is the IIS. Windows 7 has IIS7. So, The problem would be either the isapi dll or the application pool. So, started researching on those and found interesting points.

In IIS 7, application pool has a separate feature named "Managed pipeline mode". This will tell the pool the pipeline mode. [which is of type sint32 in c# and the possible values for it are 0 and 1.]

  • 0 is managed pipeline runs in integration mode.
  • 1 is managed pipeline runs in classic or ISAPI mode. [IIS 6].

In Classic mode, managed application events are executed by using ISAPI. In Integrated mode, ASP.NET request processing integrates directly into the IIS 7 request-processing pipeline. Integrated mode enables you to configure managed modules for Web sites that are developed with unmanaged code.

So, to work your logic correct, go to your site and see under what application pool your site running. Now, go to that application pool, properties and change the pipeline mode to classic mode. Now, you see everything works fine and the page starts redirecting to error page when any exception in your application.

For more details: http://msdn.microsoft.com/en-us/library/microsoft.web.administration.managedpipelinemode.aspx

Hope this helps and new tip today. Do you like this post?

No comments:

Post a Comment