[英]C#/ASP.NET MVC: how to register/log in a different web application if I know username & password?
I have a primary web app with authentication on example.com, and I have a secondary app with authentication on subdomain.example.com 我在example.com上有一个带有身份验证的主Web应用程序,在subdomain.example.com上有一个带有身份验证的辅助Web应用程序
I want the 2nd app to be integrated with the first one. 我希望第二个应用程序与第一个应用程序集成。 So once a user registers and logs in, s/he doesn't have to register/log in again. 因此,一旦用户注册并登录,他/他就不必再次注册/登录。
It is possible to send a post request, but this won't generate the cookies in user's browser... 可以发送发布请求,但这不会在用户的浏览器中生成Cookie。
How can I do that? 我怎样才能做到这一点?
Thanks 谢谢
You're able to set a cookie so that it works on all subdomains (www, subdomain, etc.). 您可以设置Cookie,使其可以在所有子域(www,子域等)上使用。 See Basics of Cookies in ASP.NET : 请参阅ASP.NET中的Cookie基础 :
By default, cookies are associated with a specific domain. 默认情况下,cookie与特定域关联。 For example, if your site is www.contoso.com, the cookies you write are sent to the server when users request any page from that site. 例如,如果您的站点是www.contoso.com,则当用户从该站点请求任何页面时,您编写的cookie就会发送到服务器。 (Except for cookies with a specific path value, as I explained in the section immediately preceding.) (如前所述,具有特定路径值的Cookie除外。)
You can also use the Domain property to create a cookie that can be shared among multiple subdomains. 您还可以使用Domain属性创建可以在多个子域之间共享的cookie。 For example, set the domain as follows: 例如,如下设置域:
Response.Cookies("domain").Value = DateTime.Now.ToString
Response.Cookies("domain").Expires = DateTime.Now.AddDays(1)
Response.Cookies("domain").Domain = "contoso.com"
The cookie will then be available to the primary domain as well as to sales.contoso.com and support.contoso.com. 然后,该Cookie将可用于主要域以及sales.contoso.com和support.contoso.com。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.