In ASP. Net, the Application usage is the same as that in ASP, and there is almost nothing to say, but it has two more useful events, Application_OnBeginRequest and Application_OnEndRequest. They are placed in the global file like the original Application_OnStart and Application_OnEnd (note that this file is named global. asa in ASP and global. asax in ASP. Net ).
Note: This event is the same if you do not write On. For example, Application_End and Application_OnEnd are the same.
Application_OnStart is in the entire ASP. net application first triggered event, that is, the first ASP. when the Net program is triggered during execution, Application_OnEnd is the opposite. It is triggered when the entire application is stopped (usually when the server is restarted/shut down ). Application_OnRequestStart and Application_OnRequestEnd occur when each ASP. Net program is requested. That is to say, the client accesses an ASP. Net program once, and these two events are triggered. We can see his application from the following program. We should first create a global. asax, the content is as follows:
<Script language = "C #" runat = "server">
Void Application_OnBeginRequest (Object sender, EventArgs E)
{
Response. Write ("Request is Starting... <br> ");
}
Void Application_OnEndRequest (Object sender, EventArgs E)
{
Response. Write ("Request is Ending... <br> ");
}
</Script>
Put it in the root directory of the local virtual directory, and then we can open any aspx file.
We are at global. request is Starting... and Request is Ending... this is not the one we add in this file. We will add another ASP. net file.