1

I have a restful WCF service that is returning JSON. I was wondering how I could compress the data? I read that HTTP has support for compression, I just don't know how to turn it on. I was sort of hoping it would be a method decoration. Below is the code for my webservice. Idealy looking for some code examples or articles to read, I've been googling and so far have come up empty, my google-foo is weak today.

[ServiceContract] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)] public class FooService { [WebInvoke(UriTemplate = "Foo", Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)] public string Foo(string aParameter) { int number = int.Parse(aParameter); number++; return "I added 1 to your number and got " + number; } } 

2 Answers 2

3

You can add GZip compression to WCF based REST enabled service.

Here's how.

Sign up to request clarification or add additional context in comments.

Comments

0

Try this C# compression, it works like a champ at doing in-memory compression! And it is Free!! http://www.codeproject.com/KB/cs/IMCompressor.aspx

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.