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
There's no notion of entry point. The way it works is that the user sends an HTTP request to an url and this url sends a response to the user. In the properties of the project you could configure which URL to launch in Visual Studio when you hit F5 because by default it launches the file you are currently editing.
Also the web server has a notion of default document i.e. if you don't specify any page it will load the default documents in the order they are configured:
The file called by default is specified on the IIS, generally is default.aspx.
the entry is an IIS ISAPI extension that processes Asp.net requests. If you want the routing you could use Asp.net mvc, or use an HttpModule to intercept and route the requests.
see more about Asp.net here. https://web.archive.org/web/20100620062357/https://www.west-wind.com/presentations/howaspnetworks/howaspnetworks.asp
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.
By default, ASP.NET just uses the physical file paths for determining which page to display. Default.aspx is the default either because it is the startup file of your project, or because it is mapped as the default document of your root folder in IIS.
You can optionally use the routing components added to the framework as part of ASP.NET MVC if you want custom routing. There's a guide on how to use this here