ASP.NETÒ³Ãæ¶ÔÏó
Ò»¡¢Cookie ¸ÅÊö
1¡¢·½°¸
Cookie ÌṩÁËÒ»ÖÖÔÚ Web Ó¦ÓóÌÐòÖд洢Óû§Ìض¨ÐÅÏ¢µÄ·½·¨¡£ÀýÈ磬µ±Óû§·ÃÎÊÄúµÄÕ¾µãʱ£¬Äú¿ÉÒÔʹÓà Cookie ´æ´¢Óû§Ê×Ñ¡Ïî»òÆäËûÐÅÏ¢¡£µ±¸ÃÓû§ÔٴηÃÎÊÄúµÄÍøվʱ£¬Ó¦ÓóÌÐò±ã¿ÉÒÔ¼ìË÷ÒÔÇ°´æ´¢µÄÐÅÏ¢¡£
2¡¢±³¾°
Cookie ÊÇһС¶ÎÎı¾ÐÅÏ¢£¬°éËæ×ÅÓû§ÇëÇóºÍÒ³ÃæÔÚ Web ·þÎñÆ÷ºÍä¯ÀÀÆ÷Ö®¼ä´«µÝ¡£Cookie °üº¬Ã¿´ÎÓû§·ÃÎÊÕ¾µãʱ Web Ó¦ÓóÌÐò¶¼¿ÉÒÔ¶ÁÈ¡µÄÐÅÏ¢¡£
ÀýÈ磬Èç¹ûÔÚÓû§ÇëÇóÕ¾µãÖеÄÒ³ÃæʱӦÓóÌÐò·¢Ë͸ø¸ÃÓû§µÄ²»½ö½öÊÇÒ»¸öÒ³Ã棬»¹ÓÐÒ»¸ö°üº¬ÈÕÆÚºÍʱ¼äµÄ Cookie£¬Óû§µÄä¯ÀÀÆ÷ÔÚ»ñµÃÒ³ÃæµÄͬʱ»¹»ñµÃÁ˸à Cookie£¬²¢½«Ëü´æ´¢ÔÚÓû§Ó²ÅÌÉϵÄij¸öÎļþ¼ÐÖС£
ÒÔºó£¬Èç¹û¸ÃÓû§ÔÙ´ÎÇëÇóÄúÕ¾µãÖеÄÒ³Ã棬µ±¸ÃÓû§ÊäÈë URL ʱ£¬ä¯ÀÀÆ÷±ã»áÔÚ±¾µØÓ²ÅÌÉϲéÕÒÓë¸Ã URL ¹ØÁªµÄ Cookie¡£Èç¹û¸Ã Cookie ´æÔÚ£¬ä¯ÀÀÆ÷±ã½«¸Ã Cookie ÓëÒ³ÇëÇóÒ»Æð·¢Ë͵½ÄúµÄÕ¾µã¡£È»ºó£¬Ó¦ÓóÌÐò±ã¿ÉÒÔÈ·¶¨¸ÃÓû§ÉϴηÃÎÊÕ¾µãµÄÈÕÆÚºÍʱ¼ä¡£Äú¿ÉÒÔʹÓÃÕâЩÐÅÏ¢ÏòÓû§ÏÔʾһÌõÏûÏ¢£¬Ò²¿ÉÒÔ¼ì²éµ½ÆÚÈÕÆÚ¡£
Cookie ÓëÍøÕ¾¹ØÁª£¬¶ø²»ÊÇÓëÌض¨µÄÒ³Ãæ¹ØÁª¡£Òò´Ë£¬ÎÞÂÛÓû§ÇëÇóÕ¾µãÖеÄÄÄÒ»¸öÒ³Ã棬ä¯ÀÀÆ÷ºÍ·þÎñÆ÷¶¼½«½»»» Cookie ÐÅÏ¢¡£Óû§·ÃÎʲ»Í¬Õ¾µãʱ£¬¸÷¸öÕ¾µã¶¼¿ÉÄÜ»áÏòÓû§µÄä¯ÀÀÆ÷·¢ËÍÒ»¸ö Cookie£»ä¯ÀÀÆ÷»á·Ö±ð´æ´¢ËùÓÐ Cookie¡£
Cookie °ïÖúÍøÕ¾´æ´¢ÓйطÃÎÊÕßµÄÐÅÏ¢¡£Ò»°ãÀ´Ëµ£¬Cookie ÊÇÒ»ÖÖ±£³Ö Web Ó¦ÓóÌÐòÁ¬ÐøÐÔ£¨¼´Ö´ÐÐ״̬¹ÜÀí£©µÄ·½·¨¡£³ý¶ÌÔݵÄʵ¼Ê½»»»ÐÅÏ¢µÄʱ¼äÍ⣬ä¯ÀÀÆ÷ºÍ Web ·þÎñÆ÷¼ä¶¼ÊǶϿªÁ¬½ÓµÄ¡£¶ÔÓÚÓû§Ïò Web ·þÎñÆ÷·¢³öµÄÿ¸öÇëÇó£¬Web ·þÎñÆ÷¶¼»áµ¥¶À´¦Àí¡£µ«ÊÇÔںܶàÇé¿öÏ£¬Web ·þÎñÆ÷ÔÚÓû§ÇëÇóҳʱʶ±ð³öÓû§»áÊ®·ÖÓÐÓá£ÀýÈ磬¹ºÎïÕ¾µãÉ쵀 Web ·þÎñÆ÷¸ú×Ùÿλ¹ºÎïÕߣ¬ÕâÑùÕ¾µã¾Í¿ÉÒÔ¹ÜÀí¹ºÎï³µºÍÆäËûµÄÓû§Ìض¨ÐÅÏ¢¡£Òò´Ë£¬Cookie ¿ÉÒÔ×÷ΪһÖÖÃûƬ£¬ÌṩÏà¹ØµÄ±êʶÐÅÏ¢°ïÖúÓ¦ÓóÌÐòÈ·¶¨ÈçºÎ¼ÌÐøÖ´ÐС£
ʹÓà Cookie Äܹ»´ïµ½¶àÖÖÄ¿µÄ£¬ËùÓÐÕâЩĿµÄ¶¼ÊÇΪÁË°ïÖúÍøÕ¾¼ÇסÓû§¡£ÀýÈ磬һ¸öʵʩÃñÒâ²âÑéµÄÕ¾µã¿ÉÒÔ¼òµ¥µØ½« Cookie ×÷Ϊһ¸ö Boolean Öµ£¬ÓÃËüÀ´Ö¸Ê¾Óû§µÄä¯ÀÀÆ÷ÊÇ·ñÒѲÎÓëÁËͶƱ£¬ÕâÑùÓû§±ãÎÞ·¨½øÐеڶþ´ÎͶƱ¡£ÒªÇóÓû§µÇ¼µÄÕ¾µãÔò¿ÉÒÔͨ¹ý Cookie À´¼Ç¼Óû§ÒѾµÇ¼£¬ÕâÑùÓû§¾Í²»±Øÿ´Î¶¼ÊäÈëƾ¾Ý¡£
3¡¢Cookie µÄÏÞÖÆ
´ó¶àÊýä¯ÀÀÆ÷Ö§³Ö×î´óΪ 4096 ×Ö½ÚµÄ Cookie¡£ÓÉÓÚÕâÏÞÖÆÁË Cookie µÄ´óС£¬×îºÃÓà Cookie
Ïà¹ØÎĵµ£º
´Ë´¦ÌṩµÄ´úÂëÓÃÀ´ÊµÏÖµ±asp.netÒ³ÃæÖеÄij¸öButton±»µã»÷ºódisableµô¸ÃÒ³ÃæÖÐËùÓеÄButton£¬´Ó¶ø·ÀÖ¹Ìá½»ÑÓʱµ¼ÖµĶà´ÎÌá½»¡£»ùÓÚ֮ǰµÄonceclickbutton½Å±¾.
//ASP.NETÖзÀÖ¹Ò³Ãæ¶à´ÎÌá½»µÄ´úÂë:javascript< script language="javascript"> < !-- function disableOtherSubmit() {
var obj = event.s ......
ÔÚASP.NETÍøÕ¾ÖÐÍøÕ¾¹ÜÀíºǫ́ÐèÒª¾³£ÑéÖ¤Óû§Éí·Ý,ҪʵÏÖÕâÖÖ¹¦ÄܾͿÉÒÔÀûÓÃÄǸö¼Ì³Ð»úÖƺÍASP.NETµÄʼþ»úÖÆ.Ê×Ïȶ¨ÒåÒ»¸öÐèÒª½øÐÐÉí·ÝÑéÖ¤µÄBasePageÀà,¼Ì³Ð×ÔPageÀà,ÔÚBasePageÀàµÄ¹¹Ô캯ÊýÖж¨ÒåËüµÄ¼ÓÔØʼþµÄ´¦Àí´úÂë,ÕâÑùËùÓм̳Ð×ÔBasePageÀàµÄÒ³Ã涼ÄÜ×Ô¶¯Ö´ÐÐÉí·ÝÑéÖ¤£º
/// <summary>
/// ÑéÖ ......
·µ»ØÉÏÒ»Ò³µÄÕâ¸ö¶«¶«ÔÚÎÒÃÇ×öÏîÄ¿µÄʱºòÒ»°ãÊÇÓÃÓÚÌîдÍê±íµ¥ºóÈ·ÈϵÄʱºò£¬ÓжÔÔÀ´ÊäÈëµÄÊý¾Ý½øÐÐÐ޸ĻòÕ߸üÐÂʱÓõģ¬»òÕßÊÇÒòΪÍøվΪÁË·½±ãä¯ÀÀÕ߶øÓÐÐÄÌí¼ÓµÄÒ»¸ö¶«¶«£¬Ò»°ãÕâÖÖ¹¦ÄܵÄʵÏÖÔÚASP.NETÖж¼ÊÇÓÃÒ»¸öButton¿Ø¼þÀ´ÊµÏֵģ¬ÊµÏֵķ½·¨Óкܶ࣬½ñÌìÇ¡ºÃÔÚ×öÏîĿʱÅöµ½ÒªÓÃÕâ¸ö¶«¶«£¬ÎҾͰÑÄÜʵÏÖ" ·µ» ......
ѧϰJQueryʱ£¬·¢ÏÖJQueryÖ»ÄÜ×öµ¥ÐÐÍÏ·Å£¬ ÓÚÊÇ»¨Ê±¼ä×öÁËÒ»¸ö¶àÐÐÍϷŵÄÀý×Ó£¬ ÒÔ±¸ÒÔºóʹÓá£
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="jquery-1.3.2.js"></scri ......
½çÃæ: Default.aspx
½çÃæÉÏÌí¼ÓµÄ¿Ø¼þ:
Á½¸öTextBox: tEmail(ÓÃÓÚÊäÈëÓû§email),tPassword(ÓÃÓÚÊäÈë×¢²áÃÜÂë)
Ò»¸öButton: bReg
Ò»¸öLabel: lLable(ÓÃÓÚ×¢²á³É¹¦ºóÏÔʾӦ´ð)
DemoµÄ´úÂë: Default.aspx.cs
ÎÒÃÇÏÈ°ÑÊý¾ÝµÄÁ¬½Ó×Ö·û´®Ð´ÔÚWeb.configÀï:
<appSettings>
<add key="oracleconn" value= ......