使用相同登录数据库的多个应用程序相互注销 [英] Multiple applications using same login database logging each other out
问题描述
我在一台机器上设置了两个 ASP.NET 应用程序,它们的 web.config 文件在 AspNetSqlMembershipProvider 项中包含相同的 applicationName 值,因此它们共享用户和角色.
I've set up two ASP.NET applications on a machine, their web.config files contain the same applicationName value in AspNetSqlMembershipProvider item so they share users and roles.
问题顺序是:
- 用户登录到应用程序 A,
- 在浏览器中打开新标签
- 登录应用程序 B,
- 他在应用程序 A 中的登录被注销
反之亦然.
我应该使用不同的方法在两个应用程序之间共享登录信息吗?
Should I use a different approach to sharing login information between two applications?
推荐答案
您遇到的问题是因为使用了相同的 cookie,用于对 2 个不同的登录进行身份验证.
The problem you have is because the same cookie used, for authenticate the 2 different logins.
据我所知,解决方案是在不同的登录名上给出不同的cookie名称,这样一个cookie就不会覆盖另一个.
The solution from what I understand is to give different cookie name on the different logins, so the one cookie, not overwrite the other one.
可能解决方案是在 web.config 上.
Probably the solution is on web.config.
更改名称值,在您的 2 个应用程序上更改为不同的内容,如果您具有相同的域并在不同的目录/应用程序上运行,或同时更改域值也用来保存 cookie.
Change the name value, to something different on your 2 apps, if you have the same domain and run on different directory/apps, or change also the domain value that used also to keep the cookie.
<authentication mode="Forms">
<forms name=".CookieSuffix" domain="yoururl.com" ... />
</authentication>
例如,在您的应用程序的 2 个不同的 web.config 上,放置
在应用 1 上:name=".app1"
在应用 2 上:name=".app2"
For example, on the 2 diferent web.config on your apps, place
on app 1: name=".app1"
on app 2: name=".app2"
或者在应用 1 上:domain="app1.yoururl.com"
在应用 2 上:domain="app2.yoururl.com"
如果你分开你的应用程序,基于 url,甚至尝试一些类似的 aproces.
Or
on app 1: domain="app1.yoururl.com"
on app 2: domain="app2.yoururl.com"
if you separate your apps, base on url, or even try some similar aproces.
cookie 是保留的,使用域名上的 cookie 名称,因此这是您必须尝试将它们分开的 2 个值.
The cookie is keep, using the cookie name on the domain name, so this is the 2 values that you must try to seperate them.
可在此处找到有关表单设置的详细信息:http://msdn.microsoft.com/en-us/library/aa480476.aspx
Details on Form setup can be found here: http://msdn.microsoft.com/en-us/library/aa480476.aspx
如果您有机会进行手动登录,解决方案就是此功能
If you have the oportunity to make manual login the solution is on this function
FormsAuthentication.GetAuthCookie(cUserName, false, "cookiePath");
FormsAuthentication.SetAuthCookie(cUserName, false, "cookiePath");
你只需要使用不同的cookiePath,但是,你必须在你的程序上改变很多点,并捕获进程登录、注销和身份验证.
You only need to use a diferent cookiePath, but, you must change many points on your program, and capture the process login, logout and Authenticate.
希望对你有帮助.
这篇关于使用相同登录数据库的多个应用程序相互注销的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!