Using system;using system.collections.generic;using system.linq;using system.web;using System.Web.UI;using System.web.ui.webcontrols;public partial class default2:system.web.ui.page{protected void Page_Load (object sender, E Ventargs e) {application["App1"] = "value1"; application["App2"] = "value2"; application["APP3"] = "value3"; int N; for (N = 0; N < Application.count; n++) {Response.Write ("Variable name:" + application.getkey (N)); Response.Write ("Variable Value:" + application.get (N) + "</br>"); } application.lock (); application["APP1"] = "Zhang"; application["App2"] = "Wang"; application["APP3"] = "Li"; Application.UnLock (); Modified variable response.write ("Modified variable Value </br>"); for (N = 0; N < Application.count; n++) {Response.Write ("Variable name:" + application.getkey (N)); Response.Write ("Variable Value:" + application.get (N) + "</br>"); }} protected void button1_click (object sender, EventArgs e) {application.lock (); application["Pageclick"] = (int) application["Pageclick"] + 1; application["uservisit"] = (int) application["Uservisit"] + 1; Application.UnLock (); Response.Write (String. Format ("page click Number:{0}<br/>", application["Pageclick"])); Response.Write (String. Format ("User access number:{0}<br/>", application["Uservisit"])); }}
<%@ application Language= "C #"%><script runat= "Server" > void Application_Start (object sender, EventArgs e) {//code running at application startup application["Count"] = 0; } void Application_End (object sender, EventArgs e) {//code to run at application shutdown} void Application_er Ror (object sender, EventArgs e) {//code to run in the event of an unhandled error} void Session_Start (object sender, EventArgs e) {//code Application.Lock () running at new session startup; application["Count"] = (int) application["Count"] + 1; Application.UnLock (); } void Session_End (object sender, EventArgs e) {//code that runs at the end of the session. Note: The Session_End event is raised only if the sessionstate mode in the Web. config file is set to//InProc. If session mode//is set to StateServer or SQL Server, the event is not raised. Application.Lock (); application["Count"] = (int) application["Count"]-1; Application.UnLock (); } </script>
The application of ASP.