Examples of Application global object usage in ASP. NET, asp. netapplication

Source: Internet
Author: User

Examples of Application global object usage in ASP. NET, asp. netapplication

The example in this article describes the Application global object usage in ASP. NET. Share it with you for your reference. The details are as follows:

Application is the Global Object of the Application and is shared by all users. No matter which page is used to operate the Application, the other page can read the Application information.

Because the Application is shared, it is locked before the operation, and then unlocked after the operation is completed.

Set Data on a page:

Application. Lock (); Application. Set ("address", "Shanghai"); Application. UnLock ();

Retrieve Data on another page:

String s = (string) Application. Get ("address"); Button1.Text = s;

Add a "Global application class" Global. asax. Execute Application_Start when the first page of the application is accessed.

For example, "count the number of accessors", Application_BeginRequest will execute the number of users when the previous content on the server is accessed. Why is this not good? High-concurrency access will be very slow!

Note: Do not use an Application for website development, and rarely use it.

I hope this article will help you design your asp.net program.

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.