开发者

HttpContext.Current.User is always null

开发者 https://www.devze.com 2022-12-17 14:44 出处:网络
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

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开发者_如何学Python Windows. In IIS Windows authentication is enabled and anon authentication disabled.

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?


Try adding -

<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

to your config file


In WCF, there is the OperationContext object from which you can retrieve the security credentials passed in by the caller/client by using the ServiceSecurityContext property.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号