Joe*_*ool 1 windows-authentication asp.net-mvc-4
我有一个ASP.NET MVC 4项目,它在Web.config中使用Windows身份验证,如下所示:
<system.web>
<authentication mode="Windows" />
</system.web>
Run Code Online (Sandbox Code Playgroud)
但是,如果我ServiceSecurityContext.Current从Controller方法调查,它是null.它不应该包含用户的身份验证信息,因为我使用的是Windows身份验证吗?
我试图解决这个问题的原因是因为我想知道CredentialCache.DefaultNetworkCredentialsController方法使用的凭据.通过阅读有关该属性的MSDN文章我收集的内容,它使用当前安全上下文的凭据...为null.
谢谢您的帮助!
这些ServiceContext类旨在用于WCF服务.它与ASP.NET MVC无关.
尝试ServiceContext.Current在ASP.NET MVC应用程序中使用就像尝试HttpContext.Current在控制台应用程序中使用=>你得到NULL.
我试图解决这个问题的原因是因为我想知道CredentialCache.DefaultNetworkCredentials在Controller方法中使用了哪些凭据
那你在寻找User.Identity.Name房产:
[Authorize]
public ActionResult Index()
{
string currentUser = User.Identity.Name;
...
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1848 次 |
| 最近记录: |