views:

423

answers:

3

I have a class Application that my global.asax inherits from. The class has this method:

protected void Application_Start(object sender, EventArgs e)
{
    // ...
}

In my understanding this is basically an event handler that is automatically added to an event (based on the method name [*]). I tried to find out what event exactly, so I put a breakpoint inside the method and checked the call stack:

Foo.DLL!Foo.Application.Application_Start(object sender = {System.Web.HttpApplicationFactory}, System.EventArgs e = {System.EventArgs})

The sender is System.Web.HttpApplicationFactory, but I can't find that class using the Object Browser in Visual Studio 2008 or on the MSDN library website.

Where can I find more information about this class?

Thank you!


[*] Compare it to the Application_BeginRequest(object sender, EventArgs e) method, which is added as a handler to the BeginRequest event of the System.Web.HttpApplication class.

+2  A: 

HttpApplicationFactory is an internal class defined in System.Web.dll. You can check it out in .NET Reflector if you are interested.

Internal means that it is not normally visible outside the dll where it is defined, so you can't use it in your own code.

Rune Grimstad
+1  A: 

Like Rune said, HttpApplicationFactory is an internal class defined in System.Web.dll.

What it does is create the application and start it, basically managing the runtime of your web application.

configurator
A: 

I have the same 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 shotly ,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 ?

Yaya