Asp.net|asp.net Global.asa must be placed in the root directory of the site
Global.asa
----------------------------------------------------------------------
<script language= "C #" runat= "Server" >
void Session_OnStart () {
Application.Lock ();
application["Whoson"]=convert.toint32 (application["Whoson"]) +1;
Application.UnLock ();
}
void Session_OnEnd () {
Application.Lock ();
application["Whoson"]=convert.toint32 (application["Whoson"])-1;
Application.UnLock ();
}
public void Application_OnStart () {
Application.Lock ();
application["Whoson"]=0;
Application.UnLock ();
}
</script>
-------------------------------------------------------------------------
Count_txt.asp
-------------------------------------------------------------------------
<%@ Page language= "C #"%>
<%@ Import namespace= "System.IO"%>
<script language= "C #" runat= "Server" >
public void Page_Load (Object Src,eventargs E)
{
The following is a read file, the current directory must have count.txt this file or it will be wrong
StreamReader Sr=file.opentext (Server.MapPath (".") + "\\count.txt");
Application.Lock ();
application["Count"]=SR. ReadLine ();
application["Count"]=convert.toint32 (application["Count"]) +1;
Application.UnLock ();
Sr. Close ();
Create a file
StreamWriter Rw=file.createtext (Server.MapPath (".") + "\\count.txt");
Application.Lock ();
rw. WriteLine (application["Count"]);
Application.UnLock ();
rw. Flush (); Write
rw. Close ();
Count_1.text= "You are the first" +application["Count". ToString () + "bit visitor";
}
</Script>
<body>
<asp:label id= "count_1" runat= "Server"/>
</body>