You can get access to HttpContext.Current
by enabling AspNetCompatibility, preferably via configuration:
<configuration>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
</system.serviceModel>
</configuration>
That in turn allows you to get access to the current user: HttpContext.Current.User
- which is what you're after, right?
You can even enforce AspNetCompatibility by decorating your service class with an additional attribute:
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
(In the System.ServiceModel.Activation
namespace.)
If that attribute is in place, your service will fail to start unless AspNetCompatibility is enabled!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…