ASP.NET SessionÏê½â
µ±Óû§ÔÚ Web Ó¦ÓóÌÐòÖе¼º½ ASP.NET ҳʱ£¬ASP.NET »á»°×´Ì¬Ê¹ÄúÄܹ»´æ´¢ºÍ¼ìË÷Óû§µÄÖµ¡£HTTP ÊÇÒ»ÖÖÎÞ״̬ÐÒé¡£ÕâÒâζ×Å Web ·þÎñÆ÷»á½«Õë¶ÔÒ³ÃæµÄÿ¸ö HTTP ÇëÇó×÷Ϊ¶ÀÁ¢µÄÇëÇó½øÐд¦Àí¡£·þÎñÆ÷²»»á±£ÁôÒÔÇ°µÄÇëÇó¹ý³ÌÖÐËùʹÓõıäÁ¿ÖµµÄÈκÎÐÅÏ¢¡£
ASP.NET »á»°×´Ì¬½«À´×ÔÏÞ¶¨Ê±¼ä·¶Î§ÄÚµÄͬһä¯ÀÀÆ÷µÄÇëÇó±êʶΪһ¸ö»á»°£¬µ±Ã¿¸öÓû§Ê×´ÎÓëÕą̂WWW·þÎñÆ÷½¨Á¢Á¬½Óʱ£¬Ëû¾ÍÓëÕâ¸ö·þÎñÆ÷½¨Á¢ÁËÒ»¸öSession£¬Í¬Ê±·þÎñÆ÷»á×Ô¶¯ÎªÆä·ÖÅäÒ»¸öSessionID£¬ÓÃÒÔ±êʶÕâ¸öÓû§µÄΨһÉí·Ý¡£SessionÌṩÓÃÓÚÔڸûỰ³ÖÐøÆÚ¼äÄÚ±£Áô±äÁ¿ÖµµÄ·½·¨¡£Ä¬ÈÏÇé¿öÏ£¬½«ÎªËùÓÐ ASP.NET Ó¦ÓóÌÐòÆôÓÃASP.NET »á»°×´Ì¬.
»á»°±äÁ¿¿ÉÒÔÊÇÈκÎÓÐЧµÄ .NET Framework ÀàÐÍ, ×¢Ò⣺µ±Ê¹Óà InProc ÒÔÍâµÄ»á»°×´Ì¬Ä£Ê½Ê±£¬»á»°±äÁ¿ÀàÐͱØÐëΪ»ùÔª .NET ÀàÐÍ»ò¿ÉÐòÁл¯µÄÀàÐÍ¡£ÕâÊÇÒòΪ»á»°±äÁ¿Öµ´æ´¢ÔÚÍⲿÊý¾Ý´æ´¢ÇøÖС£
»á»°ÓÉÒ»¸öΨһ±êʶ·û±êʶ£¬¿ÉʹÓà SessionID ÊôÐÔ¶ÁÈ¡´Ë±êʶ·û¡£Îª ASP.NET Ó¦ÓóÌÐòÆôÓûỰ״̬ʱ£¬½«¼ì²éÓ¦ÓóÌÐòÖÐÿ¸öÒ³ÃæÇëÇóÊÇ·ñÓÐä¯ÀÀÆ÷·¢Ë굀 SessionID Öµ¡£Èç¹ûδÌṩÈκΠSessionID Öµ£¬Ôò ASP.NET ½«Æô¶¯Ò»¸öлỰ£¬²¢½«¸Ã»á»°µÄ SessionID ÖµËæÏìÓ¦Ò»Æð·¢Ë͵½ä¯ÀÀÆ÷¡£
ĬÈÏÇé¿öÏ£¬SessionID Öµ´æ´¢ÔÚ Cookie ÖС£µ«Ò²¿ÉÒÔ½«Ó¦ÓóÌÐòÅäÖÃΪÔÚ“ÎÞ Cookie”»á»°µÄ URL Öд洢 SessionID Öµ¡£Ö»ÒªÒ»Ö±Ê¹ÓÃÏàͬµÄ SessionID ÖµÀ´·¢ËÍÇëÇ󣬻Ự¾Í±»ÊÓΪ»î¶¯µÄ¡£Èç¹ûÌض¨»á»°µÄÇëÇó¼ä¸ô³¬¹ýÖ¸¶¨µÄ³¬Ê±Öµ£¨ÒÔ·ÖÖÓΪµ¥Î»£©£¬Ôò¸Ã»á»°±»ÊÓΪÒѹýÆÚ¡£Ê¹ÓùýÆÚµÄ SessionID Öµ·¢Ë͵ÄÇëÇó½«Éú³ÉÒ»¸öеĻỰ¡£
°²È«ËµÃ÷£º
ÎÞÂÛÊÇ×÷Ϊ Cookie »¹ÊÇ×÷Ϊ URL µÄÒ»²¿·Ö£¬System.Web.SessionState.HttpSessionState.SessionID Öµ¶¼ÒÔÃ÷ÎĵÄÐÎʽ·¢ËÍ¡£¶ñÒâÓû§Í¨¹ý»ñÈ¡ SessionID Öµ²¢½«Æä°üº¬ÔÚ¶Ô·þÎñÆ÷µÄÇëÇóÖУ¬¿ÉÒÔ·ÃÎÊÁíһλÓû§µÄ»á»°¡£Èç¹ûÄú½«Ãô¸ÐÐÅÏ¢´æ´¢ÔڻỰ״̬ÖУ¬½¨ÒéʹÓà SSL À´¼ÓÃÜä¯ÀÀÆ÷ºÍ·þÎñÆ÷Ö®¼ä°üº¬ SessionID ÖµµÄÈκÎͨÐÅ¡£
ĬÈÏÇé¿öÏ£¬SessionID Öµ´æ´¢ÔÚä¯ÀÀÆ÷µÄ²»¹ýÆڻỰ Cookie ÖС£µ«ÊÇ£¬Í¨¹ýÔÚ Web.config ÎļþµÄ sessionState ½ÚÖн« cookieless ÊôÐÔÉèÖÃΪ true£¬¿ÉÒÔÖ¸¶¨²»Ó¦½«»á»°±êʶ·û´æ´¢ÔÚ Cookie ÖС£
<configuration>
<system.web>
<sessionState cookieless="true"
regenerateExpiredSessionId="true" /
Ïà¹ØÎĵµ£º
Ò»¡¢ÈÏʶWeb.configÎļþ
¡¡¡¡Web.configÎļþÊÇÒ»¸öXMLÎı¾Îļþ£¬ËüÓÃÀ´´¢´æ ASP.NET Web Ó¦ÓóÌÐòµÄÅäÖÃÐÅÏ¢£¨Èç×î³£ÓõÄÉèÖÃASP.NET Web Ó¦ÓóÌÐòµÄÉí·ÝÑéÖ¤·½Ê½£©£¬Ëü¿ÉÒÔ³öÏÖÔÚÓ¦ÓóÌÐòµÄÿһ¸öĿ¼ÖС£µ±Äãͨ¹ýVB.NETн¨Ò»¸öWebÓ¦ÓóÌÐòºó£¬Ä¬ÈÏÇé¿öÏ»áÔÚ¸ùĿ¼×Ô¶¯´´½¨Ò»¸öĬÈϵÄ
Web.co ......
Êý¾Ý°ó¶¨ÒÔ¼°Container.DataItemµÄ¾ßÌå·ÖÎö
Áé»îµÄÔËÓÃÊý¾Ý°ó¶¨²Ù×÷
°ó¶¨µ½¼òµ¥ÊôÐÔ:<%#UserName%>
°ó¶¨µ½¼¯ºÏ:<asp:ListBox id="ListBox1" datasource='<%# myArray%>' runat="server">
°ó¶¨µ½±í´ïʽ:<%#(class1.property1.ToString() + "," + class1.property2.ToString())%>
°ó¶¨µ½·½·¨·µ» ......
a. ReportViewer¹ØÁªReport1.rdlcµÄ¼òµ¥³ÊÏÖ
b. ¶Ô´øÓб¨±í²ÎÊýµÄReport1.rdlcµÄ³ÊÏÖ
c.
ÀûÓóÌʽÉú³ÉµÄDataSet Ìî³ä±¨±í
d. µ÷Óô洢¹ý³Ì Éú³ÉDataSet Ìî³ä±¨±í
==========
¼òµ¥µÄ³ÊÏÖ
==========
1. ´ò¿ªVS2005£¬Îļþ->н¨->ÍøÕ¾ Ñ¡ÔñÓïÑÔÖÖÀࣨC#£©
2. Ôڸýâ¾ö·½°¸ÏÂ
Éè¼ÆÆäÒѾÉú³ÉµÄDefault.aspx ......
ÍøÉϹØÓÚÍ»³öÏÔʾµ±Ç°Ò³ÃæµÄÎÄÕÂÓв»ÉÙ£¬µ«ÊÇ»ù±¾¶¼ÊǹØÓÚʵÏÖ¾²Ì¬²Ëµ¥µÄ¸ßÁÁ£¬½²µ½¶¯Ì¬Éú³É²Ëµ¥¸ßÁÁµÄÎÄÕÂÖÁÉÙÎÒûÓÐÕÒµ½£¬ÔÚcsdnÉÏÎÊÁËÁ½Ì춼ûÓд𰸣¬×îºóÔÚһλÅóÓѵĻشðÖÐÕÒµ½Ë¼Â·£¬ÏÈÀûÓÃÒ»¸öº¯ÊýÅжϲ˵¥ÊÇ·ñÊÇÕýÔÚä¯ÀÀµÄµ±Ç°Ò³£¬È»ºó¸¶¸øliÒ»¸öid£¬ÀûÓÃcss²ãµþid´óÓÚclassµÄ¹Øϵ£¬°ÑÕâ¸öid¶¨Òå³É¸ßÁÁÑùʽ¡£
aspx ......
ÎļþÉÏ´« ´ø½ø¶ÈÌõ ¶àÖÖ·ç¸ñ ·Ç³£Æ¯ÁÁ£¡
²¿·Ö´úÂ룺
<form id="form1" runat="server">
<asp:ScriptManager ID="scriptManager" runat="server" EnablePageMethods="true" />
<script type="text/javascript">
var intervalID = 0;
var progressBar;
var fileUpload;
var form;
// ½ø¶ÈÌõ
fu ......