????????
???????????ASP.NET????????????ASP.NET?????????????????????????ж???ο????????????????????????????????£???л???
????Session????
????Application??????????????????????????????????????????????
?????????Application???????????lock unlock??????????????3???????
????Application?????????????????????IIS?????Clear?????????
????Application???
???????????Application????????????????
???????????????????????Globle.asax????????????????д?????
void Application_Start(object sender?? EventArgs e)
{
// ????ó??????????е????
Application["CusCount"] = 0;
}
void Session_Start(object sender?? EventArgs e)
{
// ????????????е????
Application.Lock();
Application["CusCount"] =(int) Application["CusCount"] + 1;
Application.UnLock();
}
void Session_End(object sender?? EventArgs e)
{
// ???????????е????
// ???: ????? Web.config ????е? sessionstate ???????
// InProc ?????????? Session_End ????????????????? StateServer
// ?? SQLServer???????????????
Application.Lock();
Application["CusCount"] = (int)Application["CusCount"] - 1;
Application.UnLock();
}
????????д??????web???壬д????
????protected void Page_Load(object sender?? EventArgs e)
????{
????Response.Write("???????" + Application["CusCount"] + "λ???<br/>");
????}
???????????Application???????????????
??????????????棬д????
????protected void Page_Load(object sender?? EventArgs e)
????{
????Response.Write("???????" + Application["CusCount"] + "λ???<br/>");
????Application.Add("Key1"?? "Value1");
????Application.Add("Key1"?? "Value1");
????Application.Add("Key1"?? "Value1");
????for (int index = 0; index < Application.Count; index++)
????{
????Response.Write(Application.GetKey(index) + ": ");
????Response.Write(Application.Get(index) + "<br/>");
????}
????}
?????????????