12.0pt;line-height:125%">Applicationline-height:125%;font-family:宋體;mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman"'>狀態管理
Application["number"]=0;
Application["number"]=(int)Application["number"]+1;
12.0pt;line-height:125%">Sessionline-height:125%;font-family:宋體;mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman"'>狀態管理
this.Label2.Text=Session["who"].ToString();
Session["who"]=this.TextBox1.Text;
12.0pt;line-height:125%;color:red">Application12.0pt;line-height:125%;font-family:宋體;mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";color:red'>與Session"Times New Roman";mso-hansi-font-family:"Times New Roman";color:red'>的區別:Application"Times New Roman";mso-hansi-font-family:"Times New Roman";color:red'>傳遞對所有頁面都適用的資料,Session"Times New Roman";mso-hansi-font-family:"Times New Roman";color:red'>傳遞對特定的串連適用的資料。
狀態資訊儲存在進程外
12.0pt;line-height:125%">1)125%;font-family:宋體;mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:
"Times New Roman"'>、儲存在狀態伺服器
12.0pt;line-height:125%"><sessionState mode="StateServer" stateConnectionString="tcpip=127.0.0.1:42424" cookieless="false"
timeout="20"/>
</sessionState>
12.0pt;line-height:125%">2)125%;font-family:宋體;mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:
"Times New Roman"'>、儲存在資料庫
line-height:125%">
<sessionState mode="SQLServer"
sqlConnectionString="data source=(local);user id=sa;password=" />
125%">cookie
12.0pt;line-height:125%">//125%;font-family:宋體;mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:
"Times New Roman"'>定義line-height:125%">cookiefont-family:宋體;mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:
"Times New Roman"'>,設定其值line-height:125%">
12.0pt;line-height:125%;color:red">HttpCookie objCookie = new
HttpCookie("myCookie");
12.0pt;line-height:125%;color:red">objCookie.Values.Add("BackColor",
"Blue");
12.0pt;line-height:125%;color:red">objCookie.Expires =
DateTime.Now.AddHours(1);
12.0pt;line-height:125%;color:red">Response.Cookies.Add(objCookie);
12.0pt;line-height:125%">
12.0pt;line-height:125%">//125%;font-family:宋體;mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:
"Times New Roman"'>使用line-height:125%">cookie
12.0pt;line-height:125%;color:red">HttpCookie objCookie =
Request.Cookies["myCookie"];
Button1.BackColor=System.Drawing.Color.FromName(objCookie.Values["BackColor"]);