WCF Cookie processing and wcfcookie Processing
The cookie operation in wcf seems very simple. If you do not study in Wcf, it is still very difficult.
The figure above
The above result is just a pitfall !!!
If you don't talk much about it, go directly to the Code:
Cookie reading
1 var requestProperties = OperationContext.Current.IncomingMessageProperties;2 3 var hrp = requestProperties[HttpRequestMessageProperty.Name] as HttpRequestMessageProperty;4 5 var cookie = hrp.Headers[System.Net.HttpRequestHeader.Cookie];
Cookie writing
1 var responseProperties = OperationContext.Current.OutgoingMessageProperties;2 3 var httpResponseProperties = new HttpResponseMessageProperty();4 5 httpResponseProperties.Headers.Add(HttpResponseHeader.SetCookie, "name=yswenli");6 7 responseProperties.Add(HttpResponseMessageProperty.Name, httpResponseProperties);
The principle is that the restful function of wcf uses [webget] or [webinvoke] for operation binding. Therefore, to use web-related services, you may find them in OperationContext ~
Reprinted please note this article address: http://www.cnblogs.com/yswenli/p/7274549.html