Record the process first:
1. Modify configuration file
<System. Web>
<! -- Enable cross-site access to share sessions -->
<Httpcookies domain = "csdn. Net"/>
<! -- Set the session mode to sqlserver -->
<Sessionstate mode = "sqlserver" sqlconnectionstring = "Data Source = 127.0.0.1; user id = aspstate; Password = aspstate;" timeout = "60"/>
</System. Web>
2. Modify the tempgetappid Stored Procedure of aspstate to keep the same appid for different sites.
This is the only way to customize the appname.
/**//*
Obtain appid
Modify the process to generate only one appid
*/
Create procedure DBO. tempgetappid
@ Appname tappname,
@ Appid int output
As
Set @ appname = lower (@ appname)
Set @ appid = NULL
-- Query the appid corresponding to the appname
-- Modified at the time so that every appid is the same.
Select top 1 @ appid = appid
From [tempdb]. DBO. aspstatetempapplications
-- Where appname = @ appname
-- If no appid is found
If @ appid is null
Begin
Begin tran
-- Lock mode Query
Select @ appid = appid
-- Select top 1 @ appid = appid
From [tempdb]. DBO. aspstatetempapplications with (tablockx)
Where appname = @ appname
-- If no appid is found
If @ appid is null
Begin
-- Obtain the hashcode of appname
Exec gethashcode @ appname, @ appid output
-- Insert a new appid
Insert [tempdb]. DBO. aspstatetempapplications
Values
(@ Appid, @ appname)
If @ error = 2627
Begin
Declare @ dupapp tappname
Select @ dupapp = rtrim (appname)
From [tempdb]. DBO. aspstatetempapplications
Where appid = @ appid
Raiserror ('SQL session state fatal error: hash-code collision between applications' % s' and '% s ''. please rename the 1st application to resolve the problem. ',
18, 1, @ appname, @ dupapp)
End
End
Commit
End
Return 0
Go
There are many ways on the Internet, but they are not required by my environment.
1. Modify site IIS metadata
The IIS Site has different IDs (/lm/w3svc/1009009583/root, ID is 1009009583, usually 1 ), this method is suitable for site clusters with multiple servers (if the site ID is changed to the same on the same server, site disorder occurs ).
For step information about how to resolve different application paths between servers, see in http://support.microsoft.com/default.aspx? Ln = en-CN in the Microsoft Knowledge Base Article 325056 "PRB: session state is lost in Web farm if you use sqlserver or StateServer session mode" (PRB: if you use sqlserver or StateServer session mode, the session status will be lost in the network ).