子域身份验证

时间:2010-11-29 02:00:13

标签: c# asp.net authentication forms-authentication

我正在使用默认的ASP.NET身份验证解决方案。现在我的服务器上有子域名(例如example.com,blog.example.com,forum.example.com ......)登录发生在example.com上,并提供身份验证cookie。但是当我去forum.example.com时,我被重定向到登录。是否有配置设置使登录工作为* .example.com?

值得注意的是,Cookie是针对域名发布的“example.com”。所以我根据一些阅读将其更改为“.example.com”,现在子域验证工作正常。有谁能解释?

1 个答案:

答案 0 :(得分:0)

根据RFC 2109,如果您没有在域名前加一个点,则该名称无效,并且应拒绝该Cookie。 来自RFC 2109

  

域=域         可选的。 Domain属性指定用于的域         cookie有效。明确指定的域必须始终启动         带点。

4.3.2  Rejecting Cookies

   To prevent possible security or privacy violations, a user agent
   rejects a cookie (shall not store its information) if any of the
   following is true:

   * The value for the Path attribute is not a prefix of the request-
     URI.

   * The value for the Domain attribute contains no embedded dots or
     does not start with a dot.