ASP.NETÒ³Ãæ´«Öµ_µÚÁùƪ_Cookie
+++ Cookie01.aspxÒ³Ãæ
++ Ò³Ãæ´úÂëÈçÏ£º
<asp:TextBox ID="TextBox1" runat="server" ForeColor="Red" Width="182px">Name</asp:TextBox>
<asp:Button ID="BtnCookie" runat="server" OnClick="BtnCookie_Click" Text="BtnCookie" /><br />
++ ºǫ́´úÂëÈçÏ£º
protected void BtnCookie_Click(object sender, EventArgs e)
{
Response.Cookies["Name"].Value = TextBox1.Text;
Response.Cookies["Name"].Expires = DateTime.Now.AddDays(1);
HttpCookie aCookie = new HttpCookie("lastVisit");
aCookie.Value = DateTime.Now.ToString();
aCookie.Expires = DateTime.Now.AddDays(1);
Response.Cookies.Add(aCookie);
Response.Redirect("Cookie02.aspx");
}
+++ Cookie02.aspxÒ³Ãæ
++ Ò³Ãæ´úÂëÈçÏÂ:
(ÂÔ)
++ ºǫ́´úÂëÈçÏ£º
protected void Page_Load(object sender, EventArgs e)
{
#region ¶ÁÈ¡Cookie
if (Request.Cookies["Name"] != null)
{
Response.Write(Server.HtmlEncode(Request.Cookies["Name"].ToString()) + "</br>");
}
if (Request.Cookies["lastVisit"] != null)
{
HttpCookie aCookie = Request.Cookies["lastVisit"];
Response.Write(Server.HtmlEncode(aCookie.Value) + "</br>");
}
#endregion
Response.Write("</br>");
#region ɾ³ýCookie
HttpCookie dCookie;
string cookieName;
int limit = Request.Cookies.Count;
for (int i = 0; i < limit; i++)
{
cookieName = Request.Cookies[i].Name;
dCookie = new HttpCookie(cookieName);
dCookie.Expires = DateTime.Now.AddDays(-1);
&
Ïà¹ØÎĵµ£º
Ò»£¬Ç°ÑÔ
CookiesÏë±ØËùÓÐÈ˶¼Á˽⣬ µ«ÊÇδ±ØËùÓÐÈ˶¼¾«Í¨¡£±¾ÎĽ²½âÁËCookiesµÄ¸÷·½Ãæ֪ʶ£¬ ²¢ÇÒÌá³öÀ´ÁË×î¼Ñʵ¼ù¡£ÕâÊDZÊÕßÔÚÈÕ³£¹¤×÷ÖеĻýÀۺͳÁµí¡£
¶þ£¬»ù´¡ÖªÊ¶
1.ʲôÊÇCookies
Cookie ÊÇһС¶ÎÎı¾ÐÅÏ¢£¬°éËæ×ÅÓû§ÇëÇóºÍÒ³ÃæÔÚ Web ·þÎñÆ÷ºÍä¯ÀÀÆ÷Ö®¼ä´«µÝ¡£Cookie °üº¬Ã¿´ÎÓû§·ÃÎÊÕ¾µãʱ Web Ó¦ÓóÌÐò¶¼¿ ......
HttpContext.Current.Request.Url.ToString() ²¢²»¿É¿¿¡£
Èç¹ûµ±Ç°URLΪ
http://localhost/search.aspx?user=http://csharp.xdowns.com&tag=%BC%BC%CA%F5
ͨ¹ýHttpContext.Current.Request.Url.ToString()»ñÈ¡µ½µÄÈ´ÊÇ
http://localhost/search.aspxuser=http://csharp.xdowns.com&tag=¼&fra ......
protected void Page_Load(object sender, EventArgs e)
{
}
#region OnPreInit µÚÒ»²½
protected override void OnPreInit(EventArgs e)
{
//¼ì²é ......
ÀýÒ»£º
+++ µÚÒ»¸öÒ³Ãæ
++ Ò³Ãæ´úÂëÈçÏ£º
<div>
<a href="QueryString04.aspx?blog=DoooooNetooooot.blog.tianya.cn&qq=516535763">³¬Á´½Ó´«ÖµÊ¾Àý</a>
</div>
++ ºǫ́´úÂëÈçÏ£º
(ÂÔ)
+++ µÚ¶þ¸öÒ³Ãæ
++ Ò³Ãæ´úÂëÈçÏ£º
(ÂÔ)
++ ºǫ́´úÂëÈçÏ£º
protected void Page_Load( ......