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

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

<system.serviceModel>

    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>

</system.serviceModel>

 

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

[AspNetCompatibilityrequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]

posted @ 2010-12-30 11:03  蔡风  阅读(2075)  评论(0编辑  收藏  举报