CookieÓ¦ÓÃÍêÈ«½âÎö£¨Ò»£©£ºasp.netÖÐCookie¼¼Êõ
Cookie ÊÇʲô£¿
ÔÚasp.netÖУ¬ÈçºÎʹÓã¿
1 Cookie ÊÇʲô£¿
Cookie£ºµçÄÔÖмǼÓû§ÔÚÍøÂçÖеÄÐÐΪµÄÎļþ£»ÍøÕ¾¿Éͨ¹ýCookieÀ´Ê¶±ðÓû§ÊÇ·ñÔø¾·ÃÎʹý¸ÃÍøÕ¾¡££¨Õª×Ô http://gb.cri.cn/17004/2007/03/08/121@1487554.htm£©
2ÔÚasp.netÖУ¬ÈçºÎʹÓã¿
ASP.NETͨ¹ýSystem.Web¿Õ¼äÃû³ÆÒ²ÌṩÁËcookieµÄ·ÃÎÊ¡£ËäÈ»Äã²»Ó¦¸ÃʹÓÃcookieÀ´´æ´¢Ò»Ð©Ãô¸ÐÐÔµÄÊý¾Ý£¬µ«ÊÇ£¬ËüÃÇÊÇ´¦ÀíËøÏ¸Êý¾ÝµÄÒ»¸ö¼«ºÃµÄÑ¡Ôñ£¬±ÈÈçÑÕÉ«²ÎÊýÑ¡Ôñ»òÕß×îºóÒ»´Î·ÃÎÊÈÕÆÚ¡£
´«µÝcookies
cookieÊÇ´æ´¢ÔÚ¿Í»§¶Ë¼ÆËã»úµÄÒ»¸öСÎļþ¡£Èç¹ûÄãÊÇÒ»¸öWindowsÓû§£¬¿ÉÒÔÔÚÓû§Â·¾¶Öв鿴Cookies·¾¶£¬¼´ÎªDocuments And Settings·¾¶¡£Õâһ·¾¶°üº¬ÕâÒ»ÎļþÃû³ÆµÄÎı¾Îļþ£º
username @ Web site domain that created the cookie
(Óû§Ãû³Æ@½¨Á¢cookieµÄÕ¾µãÓòÃû)
.NET System.Web¿Õ¼äÃû³Æ°üº¬Èý¸öÀ࣬Äã¿ÉÒÔʹÓÃËüÃÇÀ´´¦Àí¿Í»§¶ËµÄCookies£º
HttpCookie£ºÌṩһ¸ö½¨Á¢ºÍ²Ù×÷¶ÀÁ¢HTTP cookiesµÄ°²È«ÀàÐ͵ķ½Ê½¡£
HttpResponse£ºCookiesÊôÐÔÔÊÐí²Ù×÷¿Í»§¶Ëcookies¡£
HttpRequest£ºCookiesÊôÐÔÔÊÐí·ÃÎʿͻ§¶Ë²Ù×÷µÄcookies¡£
HttpResponseºÍHttpRequest¶ÔÏóµÄCookiesÊôÐÔ½«·µ»ØÒ»¸öHttpCookieCollection¶ÔÏó£¬Ëü°üº¬×Å£¬½«µ¥¶ÀµÄcookiesÌí¼Óµ½¼¯ºÏ(collection)ÖУ¬ÒÔ¼°´Ó¼¯ºÏ(collection)»ñµÃÒ»¸öµ¥¶ÀµÄcookies¡£
HttpCookieÀà
HttpCookieÀàÕë¶ÔÓÚ¿Í»§´æ´¢Ö®Óöø½¨Á¢µÄµ¥¶Àcookies¡£Ò»µ©HttpCookie¶ÔÏó±»½¨Á¢£¬Äã¿ÉÒÔ½«ÆäÌí¼Óµ½HttpResponse¶ÔÏóµÄCookiesÊôÐÔÖС£Í¬ÑùµÄ£¬Äã¿ÉÒÔͨ¹ýHttpRequest¶ÔÏó·ÃÎÊÏÖÓеÄcookies¡£HttpCookieÀà°üº¬ÒÔÏµĹ«ÓÐÊôÐÔ£º
Domain(ÓòÃû)£º»ñµÃ»òÉèÖÃÓëcookieÓйصÄÓòÃû£¬¿ÉÓÃÓÚÏÞÖÆÌØ¶¨ÇøÓòµÄcookie·ÃÎÊ¡£
Expires(ÆÚÏÞ)£º»ñµÃ»òÉèÖÃcookieµÄÖÕÖ¹ÈÕÆÚºÍʱ¼ä£¬Äã¿ÉÒÔ½«ÆäÉèÖÃΪһ¸ö¹ýÈ¥µÄÈÕÆÚÒÔ×Ô¶¯ÖÕÖ¹»òÕßɾ³ýcookie¡£
Names(Ãû³Æ)£º»ñµÃ»òÉèÖÃcookieÃû³Æ¡£
Path(·¾¶)£º»ñµÃ»òÉèÖÃcookieµÄÐéÄâ·¾¶¡£ÕâÒ»ÊôÐÔÔÊÐíÄãÏÞÖÆcookie·¶Î§£¬Ò²¾ÍÊÇ˵£¬·ÃÎÊcookieÖ»ÄÜÏÞÖÆÓÚÒ»¸öÌØ¶¨µÄÎļþ¼Ð»òÕß·¾¶¡£ÉèÖÃÕâÒ»ÊôÐÔÏÞÖÆÎªÖ»ÄÜ·ÃÎÊÌØ¶¨Â·¾¶ºÍ¸Ã·¾¶ÏµÄËùÓÐÎļþ¡£
Secure(°²È«)£º·¢ÐźÅÒÔ±íʾÊÇ·ñʹÓÃSecure Sockets Layer (SSL)À´·¢ËÍcookieÖµ¡£
Value(Öµ)£º»ñµÃ»òÉèÖÃÒ»¸öµ¥¶ÀµÄcookieÖµ¡£
Values(ÐÅÏ¢)£º·µ»Ø°üº¬ÔÚcookieÖеÄkey/valueµÄÒ»¸ö¼¯ºÏ¡£
ʹÓÃÑùÀý£º
 
Ïà¹ØÎĵµ£º
ϵͳÀà
¡¡¡¡TypeÀ࣬ObjectÀ࣬StringÀ࣬ ArrayÀ࣬ConsoleÀ࣬ ExceptionÀ࣬GCÀ࣬ MarshalByRefObjectÀ࣬ MathÀà¡£
¡¡¡¡DateTime½á¹¹£¬Guid ½á¹¹£¬
¡¡¡¡ICloneable½Ó¿Ú£¬IComparable½Ó¿Ú£¬IConvertible½Ó¿Ú£¬ IDisposableÀ࣬
¡¡¡¡¼¯ºÏÀà
¡¡¡¡ICollection½Ó¿Ú£¬IComparer½Ó¿Ú£¬IDictionary½Ó¿Ú¡£IDictionaryEnume ......
Ò³Ãæ¼ÓÔØË³ÐòÈçÏÂ:
Page.Init
Page.Load
Textbox.TextChanged
Button.Click
Page.PreRender
Page.Unload
ÔÚPage.Unload֮ǰ,Ò³Ãæ¾Í³ÊÏÖ³öÀ´ÁË.
page.initÖ»ÊÇÔÚÒ³ÃæµÚÒ»´ÎÔØÈëµÄʱºòÖ´ÐÐ,µ±Ò³Ãæpostbackºó´Ópage.load¿ªÊ¼Ö´ÐÐ.
e.g
<%@ Page Language="C#" AutoEventWireup="true" CodeBe ......
Backup.aspx
protected void Button1_Click(object sender, EventArgs e)
{
string path = Server.MapPath("") + @"\Backup";
if (!Directory.Exists(path))
......
½ñÌìÓÃÁË2¸öСʱµÄʱ¼äÀ´ÅäASP.NETµÄ»·¾³£¬ÓÐЩÈË¿ÉÄÜ»áÎÊ£¬ÎªÊ²Ã´ÐèÒªÕâô¾Ã£¬´ð°¸ºÜ¼òµ¥£¬ÒòΪÎÒµÄϵͳÊÇXPÉî¶ÈµÄ~ ËùÒÔ°²×°IISºÜ·Ñ¾¢£¬½ÓÏÂÀ´ÎÒÃèÊöÏÂÎÒÔõô°²×°µÄ¡£
ǰÌ᣺
1£©ÒѾ°²×°ÁËVS2008£¬Õâ¸ö³ÌÐòÀïÃæÒѾ´øÁË.NETµÄFramwork
²½Ö裨һ¶¨Òª¿´ÍêÎÒдµÄÔÙȥŪ£¡£¡£¡£©£º
1£©ÏÖÔÚµÄÈÎÎñÊÇÈ¥ÍøÉÏÏÂÔØÒ»¸öIIS5.Xµ ......