public HttpResponseMessage Download(int fileID, bool forceDownload) { HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK); System.IO.Stream streamContent = BrowseUploadFactory.GetFileContent(fileID, out string fileName, out string contentType); result.Content = new StreamContent(streamContent); result.Content.Headers.Add("x-filename", fileName); result.Content.Headers.ContentType = new MediaTypeHeaderValue(contentType); result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue(forceDownload ? "attachment" : "inline") { FileName = fileName }; return(result); }