HttpContext.Current.User总是空 [英] HttpContext.Current.User is always null

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

问题描述

我有了返回一个Silverlight客户端,在消费服务的Windows用户名的方法的WCF服务。 WCF服务使用basicHttpBinding的与TransportCredentialOnly模式集和TransportClientCredentialType设置为Windows。在IIS的Windows身份验证启用,匿名身份验证禁用。

I have a WCF service that has a method to return the Windows Username of a Silverlight client that is consuming the service . The WCF service is using basicHttpBinding with the TransportCredentialOnly mode set and the TransportClientCredentialType set to Windows. In IIS Windows authentication is enabled and anon authentication disabled.

尽管(显然)正确地配置服务的时候我调用该服务并要求其返回的用户名是错误的。进一步检查表明,HttpContext.Current.User总是空(因此引发NullReferenceException)。

Despite (apparently) configuring the service correctly when I call the service and ask it to return the username it errors. Closer examination shows that HttpContext.Current.User is always null (so a nullreferenceexception is thrown).

没有人有任何其他想法,为什么这不工作?

Does anyone have any other ideas why this is not working?

推荐答案

尝试添加 -

<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

您的配置文件

这篇关于HttpContext.Current.User总是空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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