0
I am trying to download a report (SSRS). More specifically I want to keep it in a folder so I can print it out.
Turns out in development I don’t have any problems downloading the report. But at least I have to specify that I want to use the credentials by default:
using (var client = new WebClient())
{
client.UseDefaultCredentials = true;
}
However when I try to publish the application on the IIS server I am obliged to specify the credentials (username, password), otherwise I get an Error 403 Forbidden
or 401 Unauthorized
:
client.Credentials = new NetworkCredential("username", "password");
From my perspective the IIS Application Pool user should have enough permissions to download the report, since I also have.
This is my current code, without the printing part.
public string Print(string reportUri, string printerName)
{
using (var client = new WebClient())
{
var path = Path.ChangeExtension(Path.GetTempFileName(), "pdf");
client.UseDefaultCredentials = true;
client.DownloadFile(reportUri, path);
return path;
}
}
What I have to do to download the report in production, without specifying credentials?