【发布时间】:2013-03-21 18:29:03
【问题描述】:
我正在尝试使用适用于我的顶级域和子域的表单身份验证。
例如,如果我使用以下域登录:mydomain.com,然后转到 www.mydomain.com,我希望能够识别用户谁登录了 mydomain.com(这是同一个应用程序)。
我在我的 web.config 文件中使用以下内容:
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" domain="mydomain.com" timeout="2880" />
</authentication>
这是一个 mvc 项目,我通过以下 API 获取用户 ID:
HttpContext.Current.User.Identity.Name
对用户进行openid登录后,通过以下api创建表单认证cookie:
FormsAuthentication.SetAuthCookie(userName, createPersistentCookie);
我可以看到身份验证 cookie 被发送到两个域,但只有进行身份验证的域才能识别用户。
我做错了吗?
谢谢, 里尔
【问题讨论】:
标签: asp.net-mvc forms authentication subdomain