title: ReportViewer shows 401 unauthorized error in ASP.net
body: <p>I have a environment setup like this:</p>
  
  <p>1) SQL Server on Server A.
  2) IIS on Server B.</p>
  
  <p>SSRS report, it works fine on reporting server A. When I run the code from local development machine, it works fine. asp.net page shows the report without any issue.</p>
  
  <p>However, once I upload the asp.net to iis, it shows below error. Anyone has any idea of what this could be? It is definitely permission issue. However, in the code, I already passed the credential. I listed the code at below.</p>
  
  <pre><code>    Server Error in '/' Application.
      The request failed with HTTP status 401: Unauthorized.
  
      Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
  
      Exception Details: System.Net.WebException: The request failed with HTTP status 401: Unauthorized.
  
      Source Error:
  
      An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
  
  
      Stack Trace:
  
  
  
      [WebException: The request failed with HTTP status 401: Unauthorized.]
  
         Microsoft.Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution.RSExecutionConnection.GetSecureMethods() +232
  
         Microsoft.Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution.RSExecutionConnection.IsSecureMethod(String methodname) +60
  
         Microsoft.Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution.RSExecutionConnection.SetConnectionSSLForMethod(String methodname) +16
  
         Microsoft.Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution.ProxyMethodInvocation.Execute(RSExecutionConnection connection, ProxyMethod`1 initialMethod, ProxyMethod`1 retryMethod) +831
  
         Microsoft.Reporting.WebForms.SoapReportExecutionService.LoadReport(String report, String historyId) +34
  
         Microsoft.Reporting.WebForms.ServerReport.EnsureExecutionSession() +175
  
         Microsoft.Reporting.WebForms.ServerReport.SetParameters(IEnumerable`1 parameters) +162
  
         MvcReportViewer.ReportViewerExtensions.Initialize(ReportViewer reportViewer, ReportViewerParameters parameters) +741
  
         MvcReportViewer.MvcReportViewer.ShopReport() +469
  
         MvcReportViewer.MvcReportViewer.Page_Load(Object sender, EventArgs e) +51
  
         System.Web.UI.Control.LoadRecursive() +71
  
         System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3178
  </code></pre>
  
  <p>Here is the code:</p>
  
  <pre><code>    protected void Page_Init(object sender, EventArgs e)
      {
  
          if (!Page.IsPostBack)
          {
              ReportViewer1.ServerReport.ReportServerCredentials = new ReportServerCredentials("myId", "myPassword", "myDomain");
  
              // Set the processing mode for the ReportViewer to Remote
              ReportViewer1.ProcessingMode = ProcessingMode.Remote;
  
              ReportViewer1.ShowParameterPrompts = true;
              ReportViewer1.PromptAreaCollapsed = true;
  
              // Set the report server URL and report path
              ReportViewer1.ServerReport.ReportServerUrl =
                  new Uri("http://report.mysite.com/ReportServer");
              ReportViewer1.ServerReport.ReportPath =
                  "/Reports/myReport";
  
              // Create the sales order number report parameter
              ReportParameter MemberId = new ReportParameter();
              MemberId.Name = "MemberId";
              MemberId.Values.Add("1234567");
  
              ReportParameter DbSever = new ReportParameter();
              DbSever.Name = "DatabaseServer";
              DbSever.Values.Add("report.mysite.com");
  
              ReportParameter Dbname = new ReportParameter();
              Dbname.Name = "Database";
              Dbname.Values.Add("myDB");
  
              // Set the report parameters for the report
              ReportViewer1.ServerReport.SetParameters(
                  new ReportParameter[] { DbSever, Dbname, Uid, MemberId });
  
              ReportViewer1.ServerReport.Refresh();
          }
      }
  </code></pre>