cookie,session,application--[Asp.Net]
Cookie
写入:
HttpCookie nc=new HttpCookie("newcookie');//--实例化httpcookie
Nc.values[" name"] =xx;//--赋值
Response.cookies.Add(nc);//--写入
读取:
HttpCookie getcook=request.Cookies["newcookie"];
Response.write(getcook.value["name"]);
Application
1.在global全局里面的设置初值Application["a"]= 0;
2.加载页面里面,
Application.Lock();
Application["a"] = (int)Application["a"] + 1;
//对象类型强转成整数类型
Application.UnLock();//解锁
Response.Write(Application ["a"]);
3.global
void Application_Start(object sender, EventArgs e)
{
// 在应用程序启动时运行的代码
Application.Lock();
Application["a"] = 0;
Application.UnLock();
}
session
1.创建:global同application
2.前台直接调用:Response.Write("<br>"+Session["name"]);