Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/291.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Page.User.Identity.Name在子域页面上为空_C#_Asp.net_Iis 7_Forms Authentication - Fatal编程技术网

C# Page.User.Identity.Name在子域页面上为空

C# Page.User.Identity.Name在子域页面上为空,c#,asp.net,iis-7,forms-authentication,C#,Asp.net,Iis 7,Forms Authentication,我有多个子域试图使用一个子域进行身份验证,使用的是windows server 2008 r2上运行的窗体身份验证 所有表单验证页面都设置为使用相同的名称,并且在验证页面上,cookie添加了以下代码段: FormsAuthentication.SetAuthCookie(txtUserName.Text, false); System.Web.HttpCookie MyCookie = System.Web.Security.FormsAuthentication.GetAuthCooki

我有多个子域试图使用一个子域进行身份验证,使用的是windows server 2008 r2上运行的窗体身份验证

所有表单验证页面都设置为使用相同的名称,并且在验证页面上,cookie添加了以下代码段:

 FormsAuthentication.SetAuthCookie(txtUserName.Text, false);
 System.Web.HttpCookie MyCookie = System.Web.Security.FormsAuthentication.GetAuthCookie(User.Identity.Name.ToString(), false);
 MyCookie.Domain = ConfigurationManager.AppSettings["domainName"];
 Response.AppendCookie(MyCookie);
当我登录到signon.mysite.com时,page.user.identity.isauthenticated和page.user.identity.name属性都可以正常工作。当我导航到subdomain.mysite.com时,page.user.identity.isauthenticated返回true,但名称为空

我尝试使用以下命令从cookie中检索它,但它也是空的

 HttpCookie cookie = Request.Cookies[".ASPXAUTH"];
 FormsAuthenticationTicket fat = FormsAuthentication.Decrypt(cookie.Value);
 user2_lbl.Text = fat.Name;
在谷歌上搜索这个问题时,我发现一些人说必须在global.asax中添加一些内容,而另一些人则说没有必要

目标是能够登录到身份验证子域,并从根站点和其他子域访问用户标识。机器密钥在所有web.config中都匹配,AppSettings[domainName]当前设置为mysite.com


有人知道是什么阻止我访问用户信息吗?

将mysite.com更改为。mysite.com注意前面的


这将告诉浏览器cookie对于子域也是有效的。

将mysite.com更改为.mysite.com注意前面的


这将告诉浏览器cookie对于子域也是有效的。

这应该特别影响标识对象,但是所有站点上的web.configs是否在formsauthentication标记中都有enableCrossAppRedirects=true?这应该特别影响标识对象,但是,所有站点上的web.config是否在formsauthentication标记中都有enableCrossAppRedirects=true?请检查缓存,特别是确保没有遗留旧cookie。这当然是你的问题。它不是特定于PC的。请检查缓存,特别是确保没有遗留旧cookie。这当然是你的问题。这不是电脑特有的。