RSo*_*erg 5 c# asp.net asp.net-mvc wcf
我有一个将使用基本身份验证的WCF服务,并希望能够识别"谁"正在尝试使用该服务.我知道HttpContext.Current是NULL并且在WCF服务中,但是不知道获取用户名的替代方法.
userName = HttpContext.Current.Request.ServerVariables["LOGON_USER"];
Run Code Online (Sandbox Code Playgroud)
这样的事可能吗?
string login = OperationContext.Current
.ServiceSecurityContext
.PrimaryIdentity
.Name;
Run Code Online (Sandbox Code Playgroud)
显然,沿着该路径检查空引用异常是有帮助的,但是你明白了.
归档时间: |
|
查看次数: |
758 次 |
最近记录: |