iis-7global-asaxhttpapplication

global asax application_start application begin_request methods?


I have a problem. While migrating from classic pipeline mode to integrated pipeline mode at IIS 7.0 we encounter the problem :

Server Error in '/' Application.

Request is not available in this context...

We found solution for this problem at

mvolo.com/blogs/serverside/archive/2007/11/10/Integrated-mode-Request-is-not-available-in-this-context-in-Application_5F00_Start.aspx

As solution shortly ,in global.asax I must forward the application_start event to Application_BeginRequest event.

void Application_Start(object sender, EventArgs e) { // sender has type 'System.Web.HttpApplicationFactory' }

Application_BeginRequest(Object source, EventArgs e) | {

// sender has type 'System.Web.HttpApplication' }

Or another solution is, Application_Start event can start later then Application_BeginRequest .

any suggestions ? I have no option like choosing "classic mode "


Solution

  • Move the code to Application_BeginRequest or Session_Start. You shouldn't use the Request object in Application_Start anyway.

    The Request object contains information that is specific for one page request. It doesn't really make any sense to do anything with this information in the Application_Start event.