Just created a blank \"ASP.NET Web Application\". Where\'s the entry point?
I see \"Default.aspx\" which seems to be the default template that calls. \"Site.Master\" whi
I think I wanted to know the first line of code that gets hit when a new request comes in.
The HttpApplication
class contains the first line of code of your application. Its constructor is very much the entry point for your application. From the docs:
After all core application objects have been initialized, the application is started by creating an instance of the HttpApplication class.
There are two canonical ways to write the first line of code that gets hit for a new request. Both involve creating a Global.asax file and handling its events.
To handle application events or methods, you can create a file named Global.asax in the root directory of your application.
You will want to handle Application_Start
and/or Application_BeginRequest
.
Application_Start
is for code that gets hit on the very first request to the application. Each time we restart the application, the next request will enter here. This is per application startup.Application_BeginRequest
is for code that gets hit on each request to the application. This is per request.Of course, this all changes with ASP.NET Core.