Reputation: 25171
I have a class called Global
that derives from HttpApplication
.
Oddly, I see a lot of methods inside Global
that look like:
void Application_Start(object sender, EventArgs e)
{
}
The code is definitely executing inside this method, so the method is being called from somewhere, but where? The methods aren't marked overload?
Secondly, I derived a class from Global
, let's call it GlobalFoo
.
Again, if I create a method called Application_Start()
it will get called inside my derived class, otherwise nothing that's in Global
will get called so I might as well be deriving from an empty class.
Can anyone offer any advice? Am I missing some fundamental part of ASP.NET?
Upvotes: 7
Views: 470
Reputation: 66649
so the method is being called from somewhere, but where?
This functions are called from the Application Pool (from each pool that you have assign), to signal start-up/end events of your application and help your with initializations.
Every pool that is assign to run your web application runs those functions.
asp.net is helping you create different objects/code external or not that can run together, and that's why you see that all of your registered code run. Its a help to create more than one "start up" routines that do different thinks.
This is an example, this module just check the secure protocol by him self... and you do not need to change anything on your code, just register it.
Upvotes: 2
Reputation: 499372
IIS calls the different Global.asax events through the asp.net isapi filter.
Perhaps this article will help explain.
Upvotes: 0
Reputation: 11767
The Global.asax file is an optional file used to declare and handle application and session-level events and objects for an ASP.NET web site running on an IIS Web Server
some of the key events in this file are:
For a complete list of Global.asax events see "Global.asax Events".
Upvotes: -1