wcf - HTTPContext 在 WCF 中是否已过时?

标签 wcf

HTTPContext 在我的 WCF 调用中始终为 null,它是否已过时或者我做错了什么?

最佳答案

常规 HTTPContext 不再与 WCF 一起使用。您需要实例上下文。

[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
public class MyService : IMyService
{
    InstanceContext ic = OperationContext.Current.InstanceContext;
}

请参阅此链接了解更多详细信息

http://www.danrigsby.com/blog/index.php/2008/05/23/understanding-instancecontext-in-wcf/

您还可以启用compatibility mode因此您的 WCF 服务就像旧的 Web 服务一样,但您最好使用 InstanceContext

关于wcf - HTTPContext 在 WCF 中是否已过时?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1519809/

相关文章:

c# - 您如何处理 'You' 创建服务的 wcf 帮助页面?

c# - WCF REST 服务控制台主机

传递 Null 参数的 WCF 调用

.net - MVVM Light 如何判断哪些记录发生了变化

c# - IIS 下的多个端点

c# - 为 Web 服务创建磁盘缓存的最佳方法

asp.net - 找不到类型 'RestService.weddingservice',在 ServiceHost 指令中作为服务属性值提供

c# - WCF Web 服务返回 json 格式数据

WCF HTTPS 自托管服务不起作用 ("connection to the server was reset")

jquery 调用我的 helloworld Web 服务