-
-
Save matijagrcic/47208a43e6495baa60ba to your computer and use it in GitHub Desktop.
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
public async Task<FileStreamResult> GenerateReport() | |
{ | |
CredentialCache credentialCache = new CredentialCache(); | |
credentialCache.Add(new Uri("http://domainORipaddress"), "NTLM", new NetworkCredential( | |
ConfigurationManager.AppSettings["username"], | |
ConfigurationManager.AppSettings["password"] | |
)); | |
Stream report = null; | |
using (var httpClient = new HttpClient(new HttpClientHandler { Credentials = credentialCache })) | |
{ | |
httpClient.Timeout = TimeSpan.FromMilliseconds(Timeout.Infinite); | |
report = await httpClient.GetStreamAsync("reportUrl"); | |
} | |
var contentDisposition = new ContentDisposition | |
{ | |
FileName = "Report.pdf", | |
Inline = false | |
}; | |
Response.AppendHeader("Content-Disposition", contentDisposition.ToString()); | |
return File(report, "application/pdf"); | |
//or use | |
//Response.AppendHeader("Content-Disposition", String.Format("attachment;filename=\"{0}\"", reportName)); | |
//return File(reportPath, MediaTypeNames.Application.Pdf); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment