aspnetä¸ï¼sessioné»è®¤ä»¥inproc模å¼åå¨ï¼ä¹å°±æ¯ä¿åå¨iisè¿ç¨ä¸ï¼è¿æ ·æ个ä¼ç¹å°±æ¯æçé«ï¼ä½ä¸å©äºä¸ºæ¬è´è½½åè¡¡æ©å±ãå¯ä»¥æsessionä¿¡æ¯ä¿åå¨SQL Serverä¸ï¼æ®è¯´ï¼è¯¥ç§æ¹å¼æ¯èµ·inprocæ§è½æ失为10%-20%ãå¦ä½å®ç°å¢ï¼ä¸»è¦å两æ¥ä»ç»ï¼
1ãåå§åSQL Serverä¸çç¶ææ°æ®åº
ASP.NET SQL Server æä¾æ³¨åå·¥å
·Aspnet_regsql.exeï¼ç¨äºåå»ºä¾ ASP.NET ä¸ç SQL Server æä¾ç¨åºä½¿ç¨ç Microsoft SQL Server æ°æ®åºãAspnet_regsql.exeä½äº /%windir%/Microsoft.NET/Framework/<versionNumber>/aspnet_regsql.exe ç®å½ä¸ãå¦æ麻ç¦ï¼å¯ä»¥ ç´æ¥ç¨visual studio tools çå½ä»¤æ示工å
·ä¸ç´æ¥è¾å
¥aspnet_regsql.exe使ç¨ãç¨æ³å¦ä¸ï¼
Aspnet_regsql.exe <options>
å¯ä»¥ç¨å¦ä¸çè¯æ³æ¥æ·»å é»è®¤sessionæ°æ®åºASPState
aspnet_regsql.exe -S localhost -U sa -P why1234? -ssadd -sstype p
-Sï¼-U/-P
å¿
é¡»æ¯å¤§åï¼åå«è¡¨ç¤ºæ°æ®åºæå¡å¨ï¼ç¨æ·ååå¯ç ã
-ssadd / âssremove åæ°:
-ssadd表示æ¯æ·»å Sessionæ°æ®åº, -ssremove表示移é¤Sessionæ°æ®åº.
å建èªå®ä¹æ°æ®åºmyAppStateï¼å¯ä»¥ç¨å¦ä¸çè¯æ³ï¼
aspnet_regsql.exe -S localhost -U sa -P why1234? -ssadd -sstype c -d myAppState
2ãé
ç½®webconfig
å¨webconfigç <system.web>èä¸æ·»å å¦ä¸é
ç½®ï¼
<sessionState mode="SQLServer" sqlConnectionString="server=localhost; uid=sa; pwd=123456;"/>
å¦æå¨åå§åæ°æ®åºçæ¶åï¼å建äºèªå®ä¹æ°æ®åºå¯ä»¥ç¨ç±»ä¼¼äºå¦ä¸ççé
ç½®ï¼
<sessionState mode="SQLServer" allowCustomSqlDatabase="true" sqlConnectionString="server=localhost; DataBase=myAspState;uid=sa; pwd=123456;"/>
éè¿ä»¥ä¸ä¸¤æ¥ç设置ï¼å·²ç»å¯ä»¥äºã详ç»æ
åµè¯·åé
msdnã
温馨提示:答案为网友推荐,仅供参考