IsOneWay WCF REST服务上的WebOperationContext.Current.IncomingRequest.Headers为空 [英] WebOperationContext.Current.IncomingRequest.Headers Empty on an IsOneWay WCF REST service
问题描述
I'm experiencing an unexpected behavior within a WCF REST service that is marked as IsOneWay. 我正在将参数添加到客户端的请求标头中,在服务器端,我试图通过 I am adding params to the request headers from the client, on the server side I'm trying to access these via
Any idea how I can still access the headers with IsOneWay set? 这篇关于IsOneWay WCF REST服务上的WebOperationContext.Current.IncomingRequest.Headers为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! WebOperationContext.Current.IncomingRequest.Headers
为空.WebOperationContext.Current.IncomingRequest.Headers
. On a standard service method, the Headers collection is
filled and has the headers that I have set. When I change the method to IsOneWay however, WebOperationContext.Current.IncomingRequest.Headers
is empty.// Works
[WebInvoke(UriTemplate = "MyMethod/{id}")]
public void MyMethod(string id, object data)
{
WebOperationContext.Current.IncomingRequest.Headers.Count; // > 1
}
// Fails
[WebInvoke(UriTemplate = "MyMethod/{id}")]
[OperationContract(IsOneWay = true)] // <-- This is the issue
public void MyMethod(string id, object data)
{
WebOperationContext.Current.IncomingRequest.Headers.Count; // 0
}推荐答案
客户端发送的标头是?与提琴手确认.
are the headers sent by the client? check with fiddler.