【发布时间】:2015-12-02 05:08:47
【问题描述】:
我在 Windows 服务中创建了 WCF 数据服务并尝试访问 HttpContext。
我将此添加到我的配置文件中:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
</system.serviceModel>
但是,当我尝试访问它时,它为空。
protected override void OnStartProcessingRequest(ProcessRequestArgs args)
{
base.OnStartProcessingRequest(args);
HttpContext httpContext = HttpContext.Current;
File.AppendAllText(@"c:\Temp\ERROR.log",
httpContext != null
?"HTTPCONTEXT IS NOT NULL"
:"HTTPCONTEXT IS NULL");
}
我还应该设置什么?
【问题讨论】:
标签: c# wcf-data-services httpcontext