简体   繁体   English

无法获取HttpContext.Current.User.Identity来返回值

[英]Cant get HttpContext.Current.User.Identity to return values

This project authenticates with System.Security.Principal.WindowsIdentity 此项目使用System.Security.Principal.WindowsIdentity进行身份验证

I had a look at this: Can't get HttpContext.Current.User.Identity to work in my WebMatrix project 我看了一下: 无法让HttpContext.Current.User.Identity在我的WebMatrix项目中工作

        IIdentity WinId = HttpContext.Current.User.Identity;//returns no data
        WindowsIdentity wi = (WindowsIdentity)WinId;

I have disabled anonymous in my Web.config 我在我的Web.config中禁用了匿名

http://forums.asp.net/t/1901573.aspx?System+web+HttpContext+Current+User+Identity+Name+returns+Empty+string http://forums.asp.net/t/1901573.aspx?System+web+HttpContext+Current+User+Identity+Name+returns+Empty+string

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

The wierd part is I have another project that uses the same code and has has the same .config but works, 奇怪的是我有另一个项目使用相同的代码并具有相同的.config但是有效,

Have you wrote this in your web config ?? 你有没有在你的网络配置中写这个?

<authentication mode="Windows"/>

and please just take a look this 请看看这个

System.Web.HttpContext.Current.User.Identity.Name Vs System.Environment.UserName in ASP.NET ASP.NET中的System.Web.HttpContext.Current.User.Identity.Name与System.Environment.UserName的对比

暂无
暂无

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

相关问题 你能扩展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 如何使用HttpContext.Current.User.Identity为SmtpClient.Credentials提供身份验证? - How can I use the HttpContext.Current.User.Identity to provide authentication to my SmtpClient.Credentials? 如何在设置HttpContext.Current.User.Identity之前检查OWIN请求? - How do I check an OWIN request before HttpContext.Current.User.Identity is set? 鉴于一台服务器上的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 更改HttpContext.Current.User.Identity.Name - Changing HttpContext.Current.User.Identity.Name 模拟HttpContext.Current.User.Identity.Name - Mock HttpContext.Current.User.Identity.Name 为什么System.Web.HttpContext.Current.User.Identity.Name返回一个空字符串? - Why does System.Web.HttpContext.Current.User.Identity.Name return an empty string? HttpContext.Current.User.Identity.Name在哪里存储/访问? - Where does HttpContext.Current.User.Identity.Name get stored / accessed? HttpContext.Current.User 和 this.User.Identity 的区别 - Difference between HttpContext.Current.User and this.User.Identity
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM