HttpContext.Current.User is always null

I have a WCF service that has a way to return the Windows username of the Silverlight client that uses this service. The WCF service uses basicHttpBinding with the TransportCredentialOnly mode set and the TransportClientCredentialType setting for Windows. In IIS, Windows authentication is enabled and anonymous authentication is disabled.

Despite the (apparently) correct setting of the service when calling the service and asking it to return the username, these are errors. A closer inspection reveals that HttpContext.Current.User is always null (therefore, a nullreference exception is thrown).

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

+3
source share
2 answers

Try to add -

<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

to your configuration file

+4
source

WCF has an OperationContext object from which you can retrieve the security credentials passed by the caller / client using the ServiceSecurityContext property .

+1
source

Source: https://habr.com/ru/post/1728623/


All Articles