using System.Net; using System.Net.Http; using System.Net.Http.Headers; using System.Net.Mime; using System.Text; using System.Web; using Kreta.BusinessLogic.Classes; namespace Kreta.Web.Helpers { public static class HttpResponseExtensions { public static HttpResponseMessage GetFileHttpResponse(byte[] content, string fileName) { var result = new HttpResponseMessage(HttpStatusCode.OK) { Content = new ByteArrayContent(content) }; result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = HttpUtility.UrlEncode(fileName.ToComparableString(), Encoding.UTF8) }; result.Content.Headers.ContentType = new MediaTypeHeaderValue(MediaTypeNames.Application.Octet); return result; } } }