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);//HttpCookieÀà´´½¨cookieÈ»ºóÔÚ¹¹Ôì
Ïà¹ØÎĵµ£º
¡ï1. ʹÓÃQueryString±äÁ¿
¡¡¡¡¡¡QueryStringÊÇÒ»Öַdz£¼òµ¥µÄ´«Öµ·½Ê½£¬Ëû¿ÉÒÔ½«´«Ë͵ÄÖµÏÔʾÔÚä¯ÀÀÆ÷µÄµØÖ·À¸ÖС£Èç¹ûÊÇ´«µÝÒ»¸ö»ò¶à¸ö°²È«ÐÔÒªÇ󲻸߻òÊǽṹ¼òµ¥µÄÊýֵʱ£¬¿ÉÒÔʹÓÃÕâ¸ö·½·¨¡£µ«ÊǶÔÓÚ´«µÝÊý×é»ò¶ÔÏóµÄ»°£¬¾Í²»ÄÜÓÃÕâ¸ö·½·¨ÁË¡£ÏÂÃæÊÇÒ»¸öÀý×Ó£º
a.aspxµÄC#´úÂë
private void B ......
×÷Ϊһ¸ö³ÌÐòÔ±£¬ÔÚÍê³ÉÉè¼Æºó»¹Òª¸ù¾Ý³ÌÐòµÄÇé¿öÒÔ¼°Óû§µÄ·´Ó³²»¶Ï¶Ô³ÌÐò½øÐиĽø£¬ÕâÑù²ÅÄܲ»¶ÏµØÍêÉÆ×Ô¼ºµÄ×÷Æ·¡£±ÊÕßÔÚÖÆ×÷ÍêÈí¼þÉÌÎñÍøµÄÂÛ̳ºó£¬·¢ÏÖÈËÃÇ×Üϲ»¶ÔÚÌû×ÓÖмÓÉϸ÷ÖÖÓÐÓõÄURLÁ´½Ó»òEmailµØÖ·¡£¶ø±ÊÕßµ±³õÉè¼ÆʱûÓп¼Âǵ½ÕâÒ»µã£¬Ê¹µÃÕâЩURLÁ´½Ó»òEmailµØÖ·Ö»ÄÜÒÔÎÄ×ÖµÄÐÎʽ¶ø²¢²»ÊÇÒÔ³¬Á´½ÓµÄÐÎʽÏÔʾ ......
ASP.NETѧϰ·Ïßͼ
Èç¹ûÄãÒѾÓн϶àµÄÃæÏò¶ÔÏ󿪷¢¾Ñ飬Ìø¹ýÒÔÏÂÕâÁ½²½£º
µÚÒ»²½¡¡ÕÆÎÕÒ»ÃÅ.NETÃæÏò¶ÔÏóÓïÑÔ£¬C#»òVB.NET ÎÒÇ¿ÁÒ·´¶ÔÔÚûϵͳѧ¹ýÒ»ÃÅÃæÏò¶ÔÏó(OO)ÓïÑÔµÄÇ°ÌáÏÂȥѧASP.NET¡£ ASP.NETÊÇÒ»¸öÈ«ÃæÏò¶ÔÏóµÄ¼¼Êõ£¬²»¶®OO£¬ÄǾø¶Ôѧ²»ÏÂÈ¥!
µÚ¶þ²½¡¡¶Ô.NET FrameworkÀà¿âÓÐÒ»¶¨µÄÁ˽⠿ÉÒÔͨ¹ý¿ª·¢W ......
1.ASP.NETÔËÐÐÔÀí¸ÅÊö
¡¡¡¡ÈçÉÏͼ£¬µ±Ò»¸öhttpÇëÇó·¢Ë͹ýÀ´²¢±»IIS»úÊÕµ½Ö®ºó,IISÊ×ÏÈͨ¹ýÄãÇëÇóµÄÒ³ÃæÀàÐÍΪÆä¼ÓÔØÏàÓ¦µÄdllÎļþ£¬È»ºóÔÚ´¦Àí¹ý³ÌÖн«ÕâÌõÇëÇó·¢Ë͸øÄܹ»´¦ÀíÕâÌõÇëÇóµÄÄ£¿é,¶øÔÚASP.NETÖÐÕâ¸öÄ£¿é¾Í½Ð×öHttpHandler,ΪʲôaspxÕâÑùµÄÎļþ¿ÉÒÔ±»·þÎñÆ÷´¦Àí,ÄÇÊÇÒòΪÔÚ·þÎñÆ÷¶ËÓÐĬÈϵÄHttpHandlerרÃÅ´ ......