ASP. Net Application

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.