简体   繁体   中英

Multiple .NET Applications Share Authentication

I have 2 mvc .net applications, 1 is written in vb and the other in c#.

The are structured as follows:

The user initially logs into the /site app and has the ability to navigate to the root site.

My web.config application > authentication is as follows:

<forms 
name="SITECOOKIE" 
protection="All"  
path="/" 
domain="app1.example.com" 
timeout="15" />  

My issue is, the user logs into the http://app1.example.com/ site app where the Login controller takes care of the authentication process and sets the "SITECOOKIE". However, when navigating to the root site, http://app1.example.com , the root app cannot access or see the cookie "SITECOOKIE".

What can I do so the root app has access to the cookie "SITECOOKIE"?

You just need to set domain to example.com , if you want to share cookie between two websites.

<forms 
   name="SITECOOKIE" 
   protection="All"  
   path="/" 
   domain="example.com" 
   timeout="15" />  

Ensure you set same machinekey in both web.config file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM