How Can I Download a Report? Issue of Beliefs

Asked

Viewed 59 times

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?

1 answer

0


My Ports server and the application server were not the same. (I think) that for this reason the IIS user was not allowed to read the report.

The solution was to use a user common to both servers (because they are in the same domain) and had read access to Ports. You also need to configure the application pool user to use the same user.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.