Asp.net Identity SSO in multiple projects on localhost

风流意气都作罢 提交于 2019-12-11 19:23:40

问题


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.

So:

Website A = Admin (admin.domain.com)

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

Website C = Normal visitor website (www.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".

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.)

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


回答1:


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

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.



来源:https://stackoverflow.com/questions/31000097/asp-net-identity-sso-in-multiple-projects-on-localhost

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!