Save response as file
问题 I have WebAPI method which returns HttpResponseMessage with .csv file as Content: private static HttpResponseMessage FileAsAttachment(string file) { var now = DateTime.Now; var result = new HttpResponseMessage(HttpStatusCode.OK); result.Content = new StringContent(file); result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment"); //attachment will force download result