ASP.NET CookieʹÓÃ
1.ʲôÊÇcookie?
cookie ÊÇһС¶ÎÎı¾ÐÅÏ¢£¬°éËæÓû§ÇëÇó£¬ÔÚweb·þÎñÆ÷ºÍä¯ÀÀÆ÷Ö®¼ä´«µÝ¡£Óû§Ã¿´Î·ÃÎÊÕ¾µãµÄʱºò£¬
webÓ¦ÓóÌÐò¶¼¿ÉÒÔ¶ÁÈ¡cookie°üº¬µÄÐÅÏ¢¡£
¼ÙÉèÔÚÓû§ÇëÇóÄúµÄÍøÕ¾µÄij¸öÒ³Ãæʱ£¬ÄúµÄÓ¦ÓóÌÐò²»½öÊÇ·µ»ØÇëÇóµÄÒ³Ã档ͬʱҲ·µ»ØÒ»¸ö°üº¬ÈÕÆÚ
ºÍʱ¼äµÄcookie¡£Óû§µÄä¯ÀÀÆ÷ÔÚ»ñµÃÒ³ÃæµÄͬʱҲ»ñµÃÁËcookie.²¢ÇÒcookie±£´æÔÚ¿Í»§¶ËµÄcookieÎÄ
¼þ¼ÐÖС£
2.cookie µÄÏÞÖÆ
´ó¶àÊýä¯ÀÀÆ÷Ö§³Ö×î¶à¿É´ï4096×Ö½Ú£¨´óÔ¼4KB£©cookie.ä¯ÀÀÆ÷»¹ÏÞÖÆÁË£¬Ò»¸öÕ¾µã¿ÉÒÔÔÚ¿Í»§¶Ë±£´æ
cookieÊý¡£´ó¶àÊýä¯ÀÀÆ÷ÔÊÐíÿ¸öÕ¾µã×î¶à·Å20¸öcookie.Èç¹ûÊÔͼ±£´æ¸ü¶àµÄcookie,ÄÇôÏÈÇ°µÄcookie
½«±»É¾³ý¡£»¹ÓÐЩä¯ÀÀÆ÷»á¶ÔÀ´×ÔËùÓÐÕ¾µãcookie×ÜÊýÏÞÖÆ£¬Õâ¸öÏÞÖÆͨ³£Îª300¸ö¡£
3.cookie ÈçºÎ´´½¨
ÔÚ´´½¨cookieµÄʱºòÒªÖ¸¶¨¼¸¸öÖµ¡£×î³õ£¬ÄúÒªÖ¸¶¨cookieµÄÃû×ÖºÍÒª±£´æµÄÖµ¡£ÄúÒ²¿ÉÒÔ´´½¨¶à¸ö
cookie¡£µ«Ã¿¸öcookieµÄÃû×Ö±ØÐëΨһ£¬ÒÔ±ãÈÕºóȡֵʱʶ±ð¡££¨cookieÊÇ°´Ãû×Ö´¢´æµÄ£¬ËùÒÔÄúÒª´´½¨
Á½¸öÃû³ÆÏàͬµÄcookie£¬ÄÇô×îºóÄǸöcookie½«¸²¸ÇÇ°Ò»¸ö¡££©
ÄúÒ²¿ÉÒÔ¸øcookieÖ¸¶¨¹ýÆÚÈÕÆÚºÍʱ¼ä.cookieÊÇдÈëµ½Óû§Ó²ÅÌÉϵģ¬È»ºó¿ÉÄÜÒ»Ö±¶¼ÁôÔÚ´ÅÅÌÉÏ¡£Òò
´Ë£¬Äú¿ÉÒÔÖ¸¶¨cookieµÄ¹ýÆÚÈÕÆÚºÍʱ¼ä¡£µ±Óû§Ï´ηÃÎÊÄúµÄÕ¾µãµÄʱºò£¬ä¯ÀÀÆ÷»áÏȼì²éÄúÕ¾µãµÄËù
ÓÐcookie,Èç¹ûij¸öcookieÒѾ¹ýÆÚ£¬ä¯ÀÀÆ÷²»»á°ÑÕâ¸öcookieËæÒ³ÃæÇëÇóÒ»Æð·¢Ë͸ø·þÎñÆ÷£¬¶øÊÇɾ³ý
Õâ¸öÒѾ¹ýÆÚµÄcookie.(ÄúµÄÕ¾µã¿ÉÄÜÒѾÔÚÓû§´ÅÅÌÉÏдÈë¶à¸öcookie¡£µ«¸öÿ¸öcookieµÄ¹ýÆÚÈÕÆÚºÍ
ʱ¼ä²»Í¬)¡£ä¯ÀÀÆ÷¸ºÔð´ÅÅÌÉϵÄcookie,Õ⽫ӰÏìÄúµÄÓ¦ÓóÌÐò¶ÔcookieµÄʹÓÃ
Èç¹ûûÓÐÉèÖÃcookieµÄÓÐЧʱ¼ä,»¹ÊÇ¿ÉÒÔ´´½¨cookie£¨ÎÒÃdzÆ×ö»á»°cookie£©,»á»°cookie²»»á±£´æµ½´Å
ÅÌÉÏ£¬¶øÊDZ£´æÔÚÄÚ´æÖС£³ÉΪÓû§»á»°ÐÅÏ¢µÄÒ»²¿·Ö¡£Èç¹ûÓû§¹Ø±Õä¯ÀÀÆ÷»òÕ߻Ự³¬Ê±£¬¸Ãcookie½«
±»É¾³ý¡£ÕâÖÖ·ÇÓÀ¾ÃÐÔµÄcookie.
4.cookie ÖеĴ´½¨·½·¨
Äú¿ÉÒÔͨ¹ý¶àÖÖ·½·¨´´½¨cookieÈ»ºó°Ñcookie¶ÔÏó·Åµ½Response.Cookies¼¯ºÏÖС£ËæÇëÇóÒ³ÃæÒ»Æ𷵻ظø
ä¯ÀÀÆ÷¡£
µÚÒ»ÖÖ:
Response.Cookies("cookiename").Value="aaaa"; //´´½¨Ò»¸öÃû×ÖΪcookienameµÄcookie.È»ºóÔÚcookie
Öд洢µÄֵΪaaaa
Response.Cookies("cookiename").Expires=DateTime.Now.AddDays(1);//Ö¸¶¨cookieµÄ¹ýÆÚʱ¼äΪ1Ìì
µÚ¶þÖÖ£º
HttpCookie acookie=new HttpCookie(cookiename);//
Ïà¹ØÎĵµ£º
Beyond File | New Company: from Cheesy Sample to Social Platform Scott Hanselman in Lagoon L on Monday at 11:30 AM The web has changed and there's a new way of thinking about your applications. You can't just write some HTML and CSS anymore and expect to be the next Twitter. Hear h ......
try
{
// ÒªÌá½»±íµ¥µÄURI×Ö·û´®¡£
string uriString = "http://localhost:1165/WebTest/MyLogin.aspx";
//// ......
[url=http://www.bvbuy.cn/]·çÓïÍø[/url]
1.ǰ̨ҳÃæÒ»°ã²»ÓÃgridview datalist treeview updatepanel µÈ¿Ø¼þ£¬ÒòΪËûÃÇ»áÉú³ÉºÜ¶àÎÒ²»ÏëÒªµÄ´úÂë¡£¶øÇÒǶÌ×Ò»´ó¶Ñtable
2.ÓÃrepeater+div+css+ul liÒѾ×ã¹»ÎÒ×öºÜ¶à¶«Î÷ÁË¡£
3.·¢²¼ºóµÄÒ³Ã棬¿ÉÒÔ°ÑһЩ¿ÕÐкͻ»ÐÐ ºÍһЩ²»±ØÒªµÄ¿Õ¸ñÈ¥µô£¬¾¡Á¿¼õÉÙaspxÒ³ÃæµÄÈÝÁ¿¡£ÌḠ......
protected void Button1_Click(object sender, EventArgs e)
{
string strsql = "select * from TreeViewTemp where parentID=0";
DataTable dt = db.GetDataTable(strsql);
StringWriter sw = new StringWriter();
//StreamWriter sw = new Strea ......
Asp.Net ¹¹¼Ü(Http Handler ½éÉÜ) - Part.2
ÒýÑÔ
ÔÚ Part.1 HttpÇëÇó´¦ÀíÁ÷³Ì Ò»ÎÄÖУ¬ÎÒÃÇÁ˽âÁËHttpÇëÇóµÄ´¦Àí¹ý³ÌÒÔ¼°ÆäËüһЩÔË×÷ÔÀí¡£ÎÒÃÇÖªµÀHttp¹ÜµÀÖÐÓÐÁ½¸ö¿ÉÓýӿڣ¬Ò»¸öÊÇIHttpHandler£¬Ò»¸öÊÇIHttpModule£¬µ«ÔÚPart.1ÖУ¬ÎÒ²¢Ã»ÓÐÏêϸ½²ÊöÈçºÎ¶ÔËüÃǽøÐбà³Ì£¬Ö»ÊÇÇáÃèµÐ´µØÒ»±Ê´ø¹ý¡£ËùνѧÒÔÖÂÓã¬Ç°ÃæÒÑ ......