RedirectFromLoginPage()不会为基本域发出auth cookie

时间:2013-10-15 12:38:16

标签: asp.net authentication cookies single-sign-on

假设我有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 )

这怎么可能?

1 个答案:

答案 0 :(得分:1)

Cookie至少需要2个域名。如果您的网站是site1.local.domain&amp; site2.local.domain,然后您可以为.local.domain发出Cookie。您无法为.lo​​calhost

发出cookie
相关问题