Global. Asa must be placed in the root directory of the website. 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) { // Read the file in one directory. If the file count.txt is found in the current directory, an error occurs. 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 site" + application ["count"]. tostring () + "visitor "; } </SCRIPT> <HTML> <Head> </Head> <Body> <HR> <Asp: Label id = "count_1" runat = "server"/> </Body> </Html> |