本文介绍了本地主机上多个项目中的Asp.net Identity SSO的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有3个网站的Visual Studio解决方案.每个网站都是实时服务器上的一个子域.登录网站正在使用新的基于声明的OAuth身份认证.

I have a Visual Studio solution with 3 websites. Each website is a sub-domain on the live server. The login website is using the new claim based Identity authentication with OAuth.

所以:

Website A = Admin (admin.domain.com)

Website B = Identity Portal for logins (login.domain.com)

Website C = Normal visitor website (www.domain.com)

通过在网站B上将身份验证cookie指定为子域".domain.com",在实时服务器上可以很好地工作.

This work very well on the live server by specifying the authentication cookie on website B to be for sub-domains, ".domain.com".

我的问题是,如果我在Visual Studio中运行该项目,该如何登录网站B并保持在网站A和C上的登录状态?(我无法将Cookie设置为localhost,因为它们都使用自己的端口,例如localhost:2245.)

My question is, if i run the project in Visual Studio, how can i login on website B and stay logged in over website A and C? (I can not set the cookie to localhost since they all use their own port e.g, localhost:2245.)

我也不想仅在Visual Studio调试中在网站A和C上创建单独的登录表单.

I also do not want to create separate login forms on website A and C just for Visual Studio debugging.

推荐答案

将站点写入主机文件(c:\ Windows \ System32 \ drivers \ etc \ hosts)像这样:

Write your sites in hosts file (c:\Windows\System32\drivers\etc\hosts)Like this:

127.0.0.1     admin.domain.com
127.0.0.1     login.domain.com
127.0.0.1     www.domain.com

您可以使用任何域名(不是真实域名).然后像往常一样配置IIS绑定(一个网站的所有3个名称),就可以在浏览器中打开所有这些虚拟"网站,使用不同的Cookie,等等.为此,您将需要完整的IIS,而不是IIS Express

You can use any domain name (not real one). Then configure your IIS bindings as usual (all 3 names for one web site) and you will be able to open all these "virtual" sites in your browser, have different cookies, etc. You will need full IIS for this, not IIS express.

这篇关于本地主机上多个项目中的Asp.net Identity SSO的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 19:04