In the traditional ASP, we have to store variables applied to the entire Application with Application objects. This of course will bring the cost of memory consumption. In .NET, we can use Static variables to improve it, using Static variables in most of the time stored faster than Application objects.
practice:
Create a WebApplication, assume that name is WebApplication1, add a static member sgreeting in the Global class in Global.aspx.
Public Class Global: System.Web.httpApplication
{
Public static string sgreeting = "China is great!";
......
}
Add a Label in WebForm1, named label1.
Assign the TEXT attribute for Label1 in Page_Load ().
Private void Page_load (Object Sender, System.Eventargs E) {
Label1.text = WebApplication1.global.sgreeting;}
CHINA IS Great will be seen after running the program!