asp.netµÄsessionState½Úµã
web.config¹ØÓÚsessionState½ÚµãµÄÅäÖ÷½°¸£¬sessionStateÓÐËÄÖÖģʽ£ºoff,inProc,StateServer,SqlServer¡£
1¡¢offģʽ
´Ó×ÖÃæÉϾͿÉÒÔ¿´³öÕâ¸öÊǹرÕģʽ£¬Èç¹ûµ±Ç°Ò³Ãæ²»ÐèÒªsessionµÄÖµ£¬ÎªÁ˼õÉÙ·þÎñÆ÷×ÊÔ´£¬Äã¿ÉÒÔÈ¥µôSessionµÄ¿ªÏú¡£
<sessionState mode="off">»òÕßÒ³ÃæÉÏ
<%@ Page EnableSessionState="false" %>À´¹Ø±ÕSession¡£
2¡¢inProcģʽ(ȱʡģʽ)
ËüÔÊÐí“ÎÞCookie”µÄ»á»°£¬ÒÔ¼°ÔÚ·þÎñÆ÷Ö®Íâ´æ´¢
»á»°Êý¾Ý¡£ASP.NET»á»°×´Ì¬Ä£¿éÔÚWeb.configÎļþÖÐÏñÏÂÃæÕâÑùÅäÖãº
<sessionState mode="InProc" cookieless="false" timeout="20" />
ÔÚÕâ¸öÀý×ÓÖУ¬modeÊôÐÔÉèΪInProc£¨Ä¬ÈÏÖµ£©£¬±íÃ÷»á»°×´Ì¬ÒªÓÉASP.NET´æ´¢µ½ÄÚ´æÖУ¬ µ«ÊÇÕâÖÖ·½·¨£¬Ó¦ÓóÌÐòµÄ״̬½«ÒÀÀµÓÚ ASP.NET½ø³Ì£¬ µ±IIS½ø³Ì±ÀÀ£»òÕßÕý³£ÖØÆôʱ£¬±£´æÔÚ
½ø³ÌÖеÄ״̬½«¶ªÊ§¡£
3¡¢StateServer»á»°¹ÜÀímos
½«modeÊôÐÔÉèΪStateServer£¬Ò²¾ÍÊǽ«»á»°Êý¾Ý´æ´¢µ½µ¥¶ÀµÄÄڴ滺³åÇøÖУ¬ÔÙÓɵ¥¶Àһ̨»úÆ÷ÉÏÔËÐÐ
µÄWindows·þÎñÀ´¿ØÖÆÕâ¸ö»º³åÇø¡£×´Ì¬·þÎñÈ«³ÆÊÇ“ASP.NET State Service ”£¨aspnet_state.exe£©£¬¼ÆËã»ú¹ÜÀí-·þÎñ ÀïÃæ¼´¿É¿´µ½´Ë·þÎñ£¬Æô¶¯¸Ã·þÎñj
ËüÓÉWeb.configÎļþÖеÄstateConnectionStringÊôÐÔÀ´ÅäÖ᣸ÃÊôÐÔÖ¸¶¨ÁË·þÎñËùÔڵķþÎñÆ÷£¬ÒÔ¼°Òª¼à
ÊӵĶ˿ڣº
<sessionState mode="StateServer"
stateConnectionString="tcpip=myserver:42424"
cookieless="false" timeout="20" />
ÔÚÕâ¸öÀý×ÓÖУ¬×´Ì¬·þÎñÔÚһ̨ÃûΪmyserverµÄ»úÆ÷µÄ42424¶Ë¿Ú£¨Ä¬È϶˿ڣ©ÔËÐС£ÒªÔÚ·þÎñÆ÷Éϸıä
¶Ë¿Ú£¬¿É±à¼HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state\Parameters×¢²á±íÏîÖеÄPortÖµ¡£
ÏÔÈ»£¬Ê¹ÓÃ״̬·þÎñµÄÓŵãÔÚÓÚ½ø³Ì¸ôÀ룬²¢¿ÉÔÚWeb farm(ÍøվȺ)Öй²Ïí¡£ ʹÓÃÕâÖÖģʽ£¬»á»°×´Ì¬µÄ´æ´¢½«²»
ÒÀÀµÓÚiis½ø³ÌµÄʧ°Ü»òÕßÖØÆô£¬È»¶ø£¬Ò»µ©×´Ì¬·þÎñÖÐÖ¹£¬ËùÓлỰÊý¾Ý¶¼»á¶ªÊ§¡£»»ÑÔÖ®£¬×´Ì¬·þÎñ²»
ÏñSQL ServerÄÇÑùÄܳ־ô洢Êý¾Ý£»ËüÖ»Êǽ«Êý¾Ý´æ´¢ÔÚÄÚ´æÖС£
4 ÓÃSQL Server½øÐлỰ¹ÜÀí
ASP.NET»¹ÔÊÐí½«»á»°Êý¾Ý´æ´¢µ½Ò»¸öÊý¾Ý¿â·þÎñÆ÷ÖУ¬·½·¨Êǽ«modeÊôÐÔ±ä³ÉSqlServer¡£
ÔÚÕâÖÖÇé¿öÏ£¬ASP.NET³¢ÊÔ½«»á»°Êý¾Ý´æ´¢µ½ÓÉsqlConnectionStringÊôÐÔ£¨ÆäÖаüº¬Êý¾ÝÔ´ÒÔ¼°µÇ¼·þ
ÎñÆ÷ËùÐèµÄ°²È«Æ¾Ö¤£©Ö¸¶¨µ
Ïà¹ØÎĵµ£º
ÔÚÄãµÄPage_LoadÖÐÌí¼ÓÕâÑùµÄ´úÂë:
Page.Response.Clear();
bool success = ResponseFile(Page.Request, Page.Response, "Ä¿µÄÎļþÃû³Æ", @"Ô´Îļþ·¾¶", 1024000);
if (!success)
Response.Write("ÏÂÔØÎļþ³ö´í£¡");
Page. ......
http://zhanglei1286.blog.163.com/blog/static/1895797120091112113019600/
ÔÚºǫ́´úÂëÀ
SQL 2000:
static string StrConn = "server=.;uid=sa;pwd=sa;database=MyCUDS";
SQL2005:
con = new SqlConnection(@"Server=.\SQLExpress;Database=db_CMS;Persist Security Info=True;User ID=sa;Password=Masslong");
......
asp.netÎļþÉÏ´«£¨0£©
2009Äê04ÔÂ13ÈÕ ÐÇÆÚÒ» ÏÂÎç 06:11
Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"& ......
ÒòΪÏîÄ¿ÖÐҪʹÓÃajaxÉÏ´«Í¼Æ¬Îļþ£¬ÓÖÎÞ·¨ÕÒµ½ºÏÊʵÄjquery²å¼þ£¬Ö»ÓÐ×Ô¼º¶¯ÊÖдһ¸ö¡£Ë¼Â·ÈçÏ£º
1.ÓÃjsÈ¡µÃÎļþµÄÍêȫ·¾¶
2.ajax´«µ½ºǫ́
3.ʹÓÃwebclientµÄuploadfileÉÏ´«Îļþ¡£
Ò»ÇÐÊÓºõûÓÐÎÊÌâÁË£¬µ«ÊÇʵ¼Ê¿ª·¢ÖУ¬±¾»ú²âÊÔûÓÐÈκÎÎÊÌ⣬µ«ÊDz¿ÊðºóÈ´×ÜÊÇÕÒ²»µ½ÉÏ´«µÄÎļþ£¬µ÷ÊÔ´úÂëºó·¢ÏÖÎÞ·¨·ÃÎÊ¿Í»§¶Ë·¾¶µ ......