Context.User.Identity.Name为null [英] Context.User.Identity.Name is null

查看:142
本文介绍了Context.User.Identity.Name为null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个webservice,它有一个使用Context.User.Identity.Name作为参数的方法。由于某种原因,它是null。在IIS中进行目录设置,我检查了匿名和集成的Windows身份验证。我已经阅读了我应该取消选中匿名访问的位置,但是当我这样做时,我得到一个异常"请求失败,HTTP状态401:拒绝访问"。当我调用Web服务时,正在使用哪些凭据?在我的Web服务的web.config文件中,授权节点没有子节点。

I have a webservice that has a method that uses Context.User.Identity.Name as the parameter.  For some reason it is null.  In IIS for directory settings, I have annonymous and integrated windows authentication checked.  I have read where I should uncheck annonymous access, but when I do that, I get an exception "The request failed with HTTP status 401: Access Denied".  When I call the web service, what credentials are being used?  In my web.config file of my web service the authorization node has no child nodes. 

提前致谢

推荐答案

是在IIS中取消选中匿名。否则它将始终是匿名的,Identity.Name将为null


然后在由VS生成的代理类中,将crendentials设置为当前登录的用户:

将Dim代理设置为新的< yourWSproxyclass>
proxy.Credentials = System.Net.CredentialCache.DefaultCredentials
Yes uncheck anonymous in IIS.  Otherwise it will always be anonymous and Identity.Name will be null


Then in your proxyclass generated by VS, set the crendentials to the currently logged in user:

Dim proxy as new <yourWSproxyclass>
proxy.Credentials = System.Net.CredentialCache.DefaultCredentials


这篇关于Context.User.Identity.Name为null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆