var httpMsg = new HttpResponseMessage(HttpStatusCode.OK) { Content = new ByteArrayContent(fileData) }; httpMsg.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); httpMsg.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = HttpUtility.UrlEncode(attachment.FileName).Replace("+", "%20") }; httpMsg.Content.Headers.Expires = DateTimeOffset.MaxValue; httpMsg.Headers.ETag = new EntityTagHeaderValue(""NoChange""); httpMsg.Headers.CacheControl = new CacheControlHeaderValue() { MaxAge = TimeSpan.FromDays(365), Public = true, }; return ResponseMessage(httpMsg);
if (Request.Headers.IfNoneMatch.Any()) { return ResponseMessage(new HttpResponseMessage(HttpStatusCode.NotModified)); }