private void btnSend_Click(object sender, EventArgs e) { Data data = new Data(); data.Name = txtName.Text; data.Surname = txtSurname.Text; data.Town = txtTown.Text; data.PostalCode = txtPostalCode.Text; data.ProgramVersion = txtProgramVersion.Text; data.Email = txtEmail.Text; data.Music = txtMusic.Text; data.Singer = txtSinger.Text; data.Year = txtYear.Text; data.Hour = txtHour.Text; //serialize info string jsonString = JsonConvert.SerializeObject(data); //gzip var message = ""; byte[] inputBytes = Encoding.UTF8.GetBytes(jsonString); using (var outputStream = new MemoryStream()) { using (var gZipStream = new GZipStream(outputStream, CompressionMode.Compress)) gZipStream.Write(inputBytes, 0, inputBytes.Length); var outputBytes = outputStream.ToArray(); var outputbase64 = Convert.ToBase64String(outputBytes); message = outputbase64; } client.SendAsync(message); }