Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF Rest Service - Gaining Access to HTTP Response header

Tags:

rest

c#

http

wcf

I have a self hosted WCF Rest service that I am using to simulate a service that I do not have access to yet. (See JSON REST Service: Content-Encoding: gzip) I gziped my response, but have not found a way to set the Content-Encoding within the HTTP response header. Is there a way to get to the HTTP header object so I can set this field?

like image 883
Rob Goodwin Avatar asked Dec 13 '11 22:12

Rob Goodwin


1 Answers

you can access the response headers in your service method via the current WebOperationContext:

var response = WebOperationContext.Current.OutgoingResponse;
response.Headers.Add("Content-Encoding", "gzip");
like image 115
andyp Avatar answered Sep 28 '22 06:09

andyp