



也就是说在执行Request.IsAuthenticated时,会执行类似这样的代码,HttpCookie cookie = Request.Cookies[".DottextCookie"];我们知道Cookie是与域名关联的,HttpCookie就有个Domain属性。博客园所遇到的问题就是二级域名不能访问主域名的cookie,登录时,博客园的程序通过FormsAuthentication.SetAuthCookie设置Cookie, 而登录代码是在www.cnblogs.com域名下执行的,cookie的域名被默认设置为www.cnblogs.com, 而我们在二级域名下就无法访问这个cookie,如何解决这个问题呢?cookie的domain是否可以设置成对所有二级域名有效?在Google中苦苦寻觅,终于找到了一篇文章(Tips On Using SubDomain), 原来可以将cookie关联的域设置为".domain.ext", 博客园的设置就是.cnblogs.com。 这样,我在FormsAuthentication.SetAuthCookie之后,加上这样的代码就解决问题了:






注:
1、如果你现在还会遇到访问二级域名要重新登录的情况,请删除你计算机中相应的cookie文件,路径在C:\Documents and Settings\用户名\Cookies与C:\Documents and Settings\用户名\Local Settings\Temporary Internet Files中,文件格式为:用户名@www.cnblogs.com, 然后重新登录。
2、如果你发现其他与二级域名相关的问题,请及时与我联系。
3、如果你在访问博客园时,出现“Runtime Error”错误,那是因为刚刚更新了dll文件,你再过1、2分钟重新打开IE访问就行了。
4、现在已经全面启用二级域名。
from:http://blog.csdn.net/sunsnow8/archive/2005/07/05/413936.aspx