[Error: System.Net.WebException: Request failed with HTTP status code 401: Unauthorized.]


I have installed 2008 reporting service configured with basic credentials and to be able to generate reports I must send credentials configure an application pool in IIS and to that pool I gave a username and password with which to login in the server and this pool was associated to my project, even so I get this error     Error: System.Net.WebException: Request failed with HTTP status code 401: Unauthorized.

EDIT: the reporting service is on an external server, this works well since from the same server can be generated, the problem I think lies in the communication between team / server since it is not considering the credentials that are sent to authentication

asked by Pablo Moraga 04.01.2019 в 15:26

1 answer


One of the solutions is using the following property: ConfigurationManager.AppSettings["NombreVariable"] and in the web.config you should declare "VariableName" for its use: <add key="NombreVariable" value="ElValorQueDesees"/>

The error that you have now can be due to 2 things:

1- The application you are instantiating in the IIS does not have access to

2- Problem in the source you made. For the second I leave you an example source solution:

public class CustomSSRSCredentials : IReportServerCredentials
    private string _SSRSUserName;
    private string _SSRSPassWord;
    private string _DomainName;

    public CustomSSRSCredentials(string UserName, string PassWord, string DomainName)
        _SSRSUserName = UserName;
        _SSRSPassWord = PassWord;
        _DomainName = DomainName;

    public System.Security.Principal.WindowsIdentity ImpersonationUser
        get { return null; }

    public ICredentials NetworkCredentials
        get { return new NetworkCredential(_SSRSUserName, _SSRSPassWord, _DomainName); }

    public bool GetFormsCredentials(out Cookie authCookie, out string user,
     out string password, out string authority)
        authCookie = null;
        user = password = authority = null;
        return false;

On the page_load,

if (!Page.IsPostBack)
ReportViewer1.ProcessingMode = ProcessingMode.Remote;
IReportServerCredentials ssrscredentials = new CustomSSRSCredentials("MyUserName", "MyPassword", "ServerName");
ServerReport serverReport = ReportViewer1.ServerReport;
ReportViewer1.ServerReport.ReportServerCredentials = ssrscredentials;
serverReport.ReportServerUrl = new Uri("ReportPathKey");
serverReport.ReportPath = "/Reports/MyReport";
answered by 04.01.2019 в 15:51