Created
October 30, 2014 16:28
-
-
Save mattcanty/43f4f4bc73d9441b6e81 to your computer and use it in GitHub Desktop.
Download from web service as an attachment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static HttpResponseMessage DownloadResponse(string content, string fileName) | |
{ | |
var downloadContent = new StringContent(content); | |
var mediaType = new MediaTypeHeaderValue("application/octet-stream"); | |
var dispostition = new ContentDispositionHeaderValue("attachment") { FileName = fileName }; | |
downloadContent.Headers.ContentType = mediaType; | |
downloadContent.Headers.ContentDisposition = dispostition; | |
var result = new HttpResponseMessage(HttpStatusCode.OK) | |
{ | |
Content = downloadContent | |
}; | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment