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.
精彩评论