简体   繁体   English

鉴于一台服务器上的ASP.Net MVC站点而不是另一台服务器上的HttpContext.Current.User.Identity为空/空

[英]HttpContext.Current.User.Identity is null/empty in view of ASP.Net MVC site on one server but not the other

I have an ASP.Net MVC site that is running on an internal server. 我有一个在内部服务器上运行的ASP.Net MVC站点。 A view on the site uses @HttpContext.Current.User.Identity.Name to display the name of the user accessing the site via browser. 该站点上的视图使用@HttpContext.Current.User.Identity.Name来显示通过浏览器访问该站点的用户的名称。 The Authentication mode is set to Windows. 身份验证模式设置为Windows。

When run on one of our servers it works as expected. 在我们的一台服务器上运行时,它可以按预期工作。 When the same code is run on a second server the whole Identity object appears to be empty. 在第二台服务器上运行相同的代码时,整个Identity对象似乎为空。 This second server is a bit more isolated via firewall compared to the first server. 与第一台服务器相比,第二台服务器通过防火墙更加隔离。

What sort of rules could be preventing the Identity object from being filled? 什么样的规则可能会阻止Identity对象被填充?

In the web.config I also have 在web.config中,我也有

<authorization> <deny users="?" /> </authorization>

Which should prevent any anonymous users from accessing the site. 这样可以防止任何匿名用户访问该网站。 Since I am able to view the site I assume that it sees that I am authorized. 由于我能够查看该站点,因此我认为该站点表明我已获得授权。

  • ASP.Net MVC v5.2.7.0 ASP.Net MVC v5.2.7.0
  • .Net Framework v4.6.1 .Net Framework v4.6.1
  • Win Server 2012 IIS 8.5 Win Server 2012 IIS 8.5

Anonymous and Windows authentication were both turned on. 匿名和Windows身份验证均已打开。 Needed to turn off Anonymous. 需要关闭匿名。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ASP.net:IIS 7.5中的HttpContext.Current.User.Identity.Name为空,但在IIS Express上不是 - ASP.net: HttpContext.Current.User.Identity.Name is empty in IIS 7.5 but not on IIS Express 无法获取HttpContext.Current.User.Identity来返回值 - Cant get HttpContext.Current.User.Identity to return values 你能扩展HttpContext.Current.User.Identity属性吗? - Can you extend HttpContext.Current.User.Identity properties 使用formsauthentication进行登录并使用HttpContext.Current.User.Identity - Using formsauthentication for login and use HttpContext.Current.User.Identity 在ASP.NET MVC中扩展HttpContext.User.Identity - extend HttpContext.User.Identity in asp.net mvc 自定义asp.net身份存储-为什么HttpContext.Current有时为空 - custom asp.net identity store - why is HttpContext.Current empty at times Asp.net MVC身份当前用户到剃刀视图的路径返回错误/将模型项传递到字典中 - Asp.net mvc identity current user path to razor view return error / The model item passed into the dictionary ASP.NET 核心 MVC 身份 - 如何查看当前登录的用户? - ASP.NET Core MVC Identity - how to get current logged in user in view? ASP.NET中的System.Web.HttpContext.Current.User.Identity.Name与System.Environment.UserName的对比 - System.Web.HttpContext.Current.User.Identity.Name Vs System.Environment.UserName in ASP.NET 如何使用HttpContext.Current.User.Identity为SmtpClient.Credentials提供身份验证? - How can I use the HttpContext.Current.User.Identity to provide authentication to my SmtpClient.Credentials?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM