Read this first: ASP.net supports Forms authentication in a distributed environment (across multiple applications on a single server or in a Web farm).
Before studying too much session sharing between sites, here's a detailed implementation of forms authentication across applications, which is based on "Forms Authentication across Applications" (Help clickable links or find MSDN yourself directly).
To create two Web application-level projects in VS2005, two projects add a Default.aspx page, one of which adds Login.aspx pages and implements Forms authentication.
Add the following code to the Default.aspx.cs code page of the two project: View Plaincopy to Clipboardprint?
Response.Write (User.Identity.Name); Output user name logged in after current form authentication
Response.Write (User.Identity.Name); The user name that is logged in after the current form authentication is exported assumes that the address of two items is as follows:
Item A: http://localhost/test/
Item B (with login): http://localhost:81/
From the above address can be seen two projects under different domain names, that is, two projects in two different Web sites
Set the Web.configview plaincopy to Clipboardprint for item a?
<authentication mode = "Forms">
<!-
Here loginUrl is the login page pointing to Project B
Note: The name, protection, path, validationKey, validation, decryptionKey, and decryption attributes must be exactly the same in all applications
->
<forms loginUrl = "http: localhost: 81 / Login.aspx" path = "/" protection = "All" defaultUrl = "http: localhost: 81 / Default.aspx" timeout = "40" name = ". DeESoft">
</ forms>
</ authentication>
<machineKey
validationKey = "C50B3C89CB21F4F1422FF158A5B42D0E8DB8CB5CDA1742572A487D9401E3400267682B202B746511891C1BAF47F8D25C07F6C39A104696DB51F17C529AD3CABE"
decryptionKey = "8A9BE8FD67AF6979E7D20198CFEA50DD3D3799C77AF2B72F"
validation = "SHA1"
<authorization>
<deny users = "?"
</ authorization>
<authentication mode = "Forms">
<!-
Here loginUrl is the login page pointing to project B
Note: The name, protection, path, validationKey, validation, decryptionKey, and decryption attributes must be exactly the same in all applications
->
<forms loginUrl = "http: localhost: 81 / Login.aspx" path = "/" protection = "All" defaultUrl = "http: localhost: 81 / Default.aspx" timeout = "40" name = ". DeESoft">
</ forms>
</ authentication>
<machineKey
validationKey = "C50B3C89CB21F4F1422FF158A5B42D0E8DB8CB5CDA1742572A487D9401E3400267682B202B746511891C1BAF47F8D25C07F6C39A104696DB51F17C529AD3CABE"
decryptionKey = "8A9BE8FD67AF6979E7D20198CFEA50DD3D3799C77AF2B72F"
validation = "SHA1" />
<authorization>
<deny users = "?" />
</ authorization>