I have a ASP.NET MVC web action which returns a simple zip file. The Responce.ContentType property is manually set to "text/xml; charset=utf-8; gzip". This header value is set before writing response content to the output stream. Web project is hosted on Windows Azure hosting. The problem is that sometimes server returns response with missing ContentType header field, this causes issues on the client side. Having no idea what could be the reason of it. When I run same web project locally - everything works fine, ContentType field has proper value. Sample web action code:
public void GetData()
{
Response.ContentType = "text/xml; charset=utf-8; gzip";
XDocument xml = new XDocument(...);//some large XML file
byte[] byteData = Encoding.UTF8.GetBytes(xml.ToString());
Stream outputStream = Response.OutputStream;
GZipStream compressedzipStream = new GZipStream(outputStream, CompressionMode.Compress);
compressedzipStream.Write(byteData, 0, byteData.Length);
compressedzipStream.Close();
}
Any help would be much appreciated.