使用相同的登录数据库登录对方出多个应用程序 [英] Multiple applications using same login database logging each other out

查看:92
本文介绍了使用相同的登录数据库登录对方出多个应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设置了两个 ASP.NET应用程序一台机器上,他们的web.config文件中包含同样的的applicationName 的中的 AspNetSqlMembershipProvider 的项目,以便他们共享用户和角色的价值。

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,

  • 他的应用程序中的登录,注销

,反之亦然。

我应该使用不同的方法来共享登录信息两个应用程序之间?

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应用程序,如果你有相同的域,并在不同的目录/ apps跑,或也更改域值所用也保持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 diferent web.config中,地方结果
在应用1: NAME =APP1结果
在App 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:域=app1.yoururl.com结果
在App 2:域=app2.yoururl.com结果
如果您在网址分开你的应用程序,基地,甚至尝试一些类似的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名称,所以这是两个值,你必须设法它们分开。

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.

表格设置详细信息可以在这里找到:
<一href=\"http://msdn.microsoft.com/en-us/library/aa480476.aspx\">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

如果你有oportunity进行手动登录该解决方案是此功能

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");

您只需要使用一个diferent 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆