In general we all know that we compress the data and
post it to the web server and the server decompresses the data to process the
request. This is done to optimize the server performance and gain the bandwidth
benefit. In this article I will be explaining how to compress a file using
GZipStream utility in .Net and post it to the server. And also how the server
application decompresses the data and executes the request. I will be
demonstrating the whole process using a windows form application which posts the
compressed data to the Asp.Net application which is hosted on the IIS
server.

GZipStream

Before further delving into the details, I would like to
explain what GZipStream is. GZipStream is used to compress the data in gzip
format. GZipStream compress with namespace System.IO.Compress. Sending the gzip
compressed data to server reduces the file size and gets the bandwidth benefit.
Using the GZipStream class we can work in such a way with data in memory, as
well as in disk.

Client Code for compressing the file using C#.Net

Take a windows form application and drag a button on to
the form. On the click event of the button write the following code.

Though the Compression and Decompression is the familiar
concept known to all, this article mainly speaks about basics of how to compress
the data using GzipStream on the client application and post to the server. And
how the server application developed in Asp.Net receives the data and
decompresses it.