WCF Service中HttpContext.Current为null的解决办法

1. 在hosting WCF的web.config中加入:

<system.serviceModel>

    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>

</system.serviceModel>

 

2. 在Service的类定义上加上下面Attribute:

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]

你可能感兴趣的:(service)