假设我有2个网站,并希望在它们之间实施SSO。它们托管在 site1.localhost 和 site2.localhost 中。从我到目前为止所读到的,我只需要在web.config中使用以下内容:
<authentication mode="Forms">
<forms loginUrl="/Login.aspx" domain=".localhost" path="/" />
<machineKey .../>
</authentication>
但是,以下调用根本不会发出身份验证cookie:
FormsAuthentication.RedirectFromLoginPage(InputEmail.Text, true);
如果我从domain
元素中删除forms
属性,则会为 site1.localhost 域完美地发布Cookie。我错过了什么?
P.S。
Windows 7 x64,ASP.NET 4.0,集成管道,无额外模块/处理程序
更新
以下调用返回具有正确域集的cookie( .localhost ):
HttpCookie httpCookie = FormsAuthentication.GetAuthCookie(InputEmail.Text, true )
这怎么可能?
答案 0 :(得分:1)
Cookie至少需要2个域名。如果您的网站是site1.local.domain
&amp; site2.local.domain
,然后您可以为.local.domain
发出Cookie。您无法为.localhost