There would be an iOS App
and the .NET WebApi
which would require to sync large data or records.
We need to have in Memory Compression on both iOS and .NET WebApi which would compress
and decompress
the data and then further process.
On iOS App side, we have planned to use in Memory GZip
compression using something like below-
http://www.clintharris.net/2009/how-to-gzip-data-in-memory-using-objective-c/
http://www.deusty.com/2007/07/gzip-compressiondecompression.html
On .Net WebApi side, we have planned to use the GZip compression to be developed using- https://msdn.microsoft.com/en-us/library/system.io.compression.gzipstream%28v=vs.110%29.aspx
Now my question is-
Is it possible to use the GZipStream
Class in .Net to compress the JSON
string? In .Net data would be fetched from the database into models and then the models would be converted to JSON strings and then that string needs to be compressed before sending to device and same inverse process would be followed when receiving data from the iOS App.
Is there any other best approach then the above which we have planned? Any technical advice, relevant links or some sample code snippet would be very helpful.
The Solution: Thanks to @puneet for leading this post to get a proper solution.
As my server application is a Asp.Net WebAPI and doesn't have any files (html, css, js etc.) to be transferred from the server to browsers like any traditional website. http://forums.asp.net/t/1771770.aspx
Therefore the Automatic IIS Compression would not work in my case, which can be enabled by following the steps given here- http://www.codeproject.com/Articles/186233/Utilize-gzip-compression-in-IIS
In my case both GZip Requests and Responses need to be handled and for this purpose seperate handlers would be required and in that case I am following these below SO posts-
For Compression: Compress HTTP GET Response
For Decompression: How do enable a .Net web-API to accept g-ziped posts
Another mentionable link- http://benfoster.io/blog/aspnet-web-api-compression