Asp. In net Forms authentication across applications

Source: Internet
Author: User
Tags sha1


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>




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.