/// <summary> /// Write KML document as binary data directly into response OutputStream. /// </summary> /// <param name="context">ControllerContext in which execute operates</param> public override void ExecuteResult(ControllerContext context) { context.HttpContext.Response.Clear(); context.HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache); context.HttpContext.Response.ContentType = IsCompressed ? KMZ_MIME_TYPE : KML_MIME_TYPE; Kml kml = new Kml(Document); using (var stream = IsCompressed ? new MemoryStream(kml.ToKmz()) : new MemoryStream(Encoding.UTF8.GetBytes(kml.ToString()))) { stream.WriteTo(context.HttpContext.Response.OutputStream); } }