重叠用户登录与ASP.NET识别两个项目 [英] Overlap User Login in Two Projects with ASP.NET Identity
问题描述
我在asp.net身份问题,我无法理解。
I have a problem I can not understand in asp.net identity
应用以下步骤
- 创建两个空Web项目,他们的名字:
- WebApplication1
- WebApplication2
- WebDatabase1
- WebDatabase2
我的问题是,当我登录的用户1 中的 WebApplication1
My problem is when I Login by "User1" in "WebApplication1"
我觉得 WebApplication2 登录是用户1
尽管每个项目都有单独的数据库。
despite each project have separate database.
和也否用户1 在 WebApplication2
什么是问题?
请原谅我的英语不好!
Excuse my bad English!
推荐答案
当用户登录到该网站中,auth中间件序列化登录的用户信息(包括ID,名称和角色)到加密的身份验证cookie中。在随后的访问中,框架简单地解密并读取信息,而无需访问数据库。
When a user signs into the site, the auth middleware serializes the logged in user information (including the id, name, and roles) into the encrypted auth cookie. On subsequent visits, the framework simply decrypts and reads that information without hitting the database.
在默认情况下,相同的cookie名称在ASP.NET应用程序中使用。你所看到的情况是WebApp1设置cookie,并webapp2的阅读。这是因为他们是在同一个域(或本地主机)和饼干在同一个域跨资源共享。
By default, the same cookie name is used across ASP.NET applications. What you see happening is WebApp1 setting the cookie, and WebApp2 reading it. This is because they're on the same domain (or localhost) and cookies are shared across resources on the same domain.
试着在你的应用程序更改cookie名称...
Try changing the cookie name in your applications...
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
// ...
CookieName = "WebApp1AuthCookie"
});
这篇关于重叠用户登录与ASP.NET识别两个项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!