Use MemoryStream and ZipArchive to return zip file to client in asp.net web api
<p>I am trying to return zip file from asp.net web api to client using The following Code:</p>

<pre><code>private byte[] CreateZip(string data)
{
    using (var ms = new MemoryStream())
    {
        using (var ar = new ZipArchive(ms, ZipArchiveMode.Create, true))
        {
            var file = archive.CreateEntry("file.html");

            using (var entryStream = file.Open())
            using (var sw = new StreamWriter(entryStream))
            {
                sw .Write(value);
            }
        }
        return memoryStream.ToArray();
    }
}

public HttpResponseMessage Post([FromBody] string data)
{
    HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);
    result.Content = new ByteArrayContent(CreateZip(data));
    result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/zip, application/octet-stream");
    return result;
}
</code></pre>

<p>When i run this code i get the following error:</p>

<blockquote>
  <p>ExceptionMessage":"The format of value 'application/zip,
  application/octet-stream' is invalid."</p>
</blockquote>

<p>this is the JS code: </p>

<pre><code>$.ajax({
  type: "POST",
  url: url,
  data: data,
  dataType: application/x-www-form-urlencoded
});
</code></pre>

<p>Any explanation why this is happen? I would really appriciate your help guys</p>