Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Report Viewer Error :: The request failed with HTTP status 401: Unauthorized.


Report Viewer Error :: The request failed with HTTP status 401: Unauthorized.

Author
Message
Sol_Web_Solutions
Sol_Web_Solutions
SSC-Enthusiastic
SSC-Enthusiastic (116 reputation)SSC-Enthusiastic (116 reputation)SSC-Enthusiastic (116 reputation)SSC-Enthusiastic (116 reputation)SSC-Enthusiastic (116 reputation)SSC-Enthusiastic (116 reputation)SSC-Enthusiastic (116 reputation)SSC-Enthusiastic (116 reputation)

Group: General Forum Members
Points: 116 Visits: 168
I'm trying to call a report viewer from a page prompting for three parameters:
1. Dropdown list value
2. Start Date
3. End Date

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:


Line 51:
Line 52: // Set the report parameters for the report
Line 53: ReportViewer1.ServerReport.SetParameters(



***********************
***********************

The class I'm using is:

[Serializable()]
public sealed class MyReportServerCredentials2 : IReportServerCredentials
{
#region IReportServerCredentials Members

private string credUser;
private string credPassword;
private string credDomain;

public MyReportServerCredentials2(string user, string password, string domain)
{
credUser = user;
credPassword = password;
credDomain = domain;
}
public WindowsIdentity ImpersonationUser
{

//Use the default windows user. Credentials will be
//provided by the NetworkCredentials property.
get { return null; }

}
public ICredentials NetworkCredentials
{
get
{

//Read the user information from the web.config file.
//By reading the information on demand instead of storing
//it, the credentials will not be stored in session,
//reducing the vulnerable surface area to the web.config
//file, which can be secured with an ACL.

//User name
string userName = credUser;

//Dim userName As String = _
// ConfigurationManager.AppSettings("MyReportViewerUser")

if ((string.IsNullOrEmpty(userName)))
{
throw new Exception("Missing user name from web.config file");
}

//Password
string password = credPassword;

//Dim password As String = _
// ConfigurationManager.AppSettings("MyReportViewerPassword")

if ((string.IsNullOrEmpty(password)))
{
throw new Exception("Missing password from web.config file");
}

//Domain
string domain = credDomain;

//Dim domain As String = _
// ConfigurationManager.AppSettings("MyReportViewerDomain")

if ((string.IsNullOrEmpty(domain)))
{
throw new Exception("Missing domain from web.config file");
}

return new NetworkCredential(userName, password, domain);
}
}
public bool GetFormsCredentials(out Cookie authCookie, out string userName, out string password, out string authority)
{

authCookie = null;
userName = null;
password = null;
authority = null;

//Not using form credentials
return false;

}
#endregion
}


********************
********************
The above class is called in my code behind page_load as:

if (!Page.IsPostBack)
{
// Set the processing mode for the ReportViewer to Remote
ReportViewer1.ProcessingMode = ProcessingMode.Remote;
ServerReport serverReport = ReportViewer1.ServerReport;
ReportViewer1.ServerReport.ReportServerCredentials = new MyReportServerCredentials2("user", "password", "domain");


// Set the report server URL and report path
serverReport.ReportServerUrl = new Uri("http://Mydomain/reportserver");
serverReport.ReportPath = "/correctfolder";

// Create the sales order number report parameter
ReportParameter rpDivision = new ReportParameter();
rpDivision.Name = "Division";
string rqsDivision = Request.QueryString["Division"];
rpDivision.Values.Add(rqsDivision);

// Set the report parameters for the report
ReportViewer1.ServerReport.SetParameters(
new ReportParameter[] { rpDivision });
}



*******************
*******************


In my web.config I have:









<identity impersonate="true" userName="registry:HKLM\SOFTWARE\...\ASPNET_SETREG,userName"

password="registry:HKLM\SOFTWARE\...\ASPNET_SETREG,password" />


*******************
*******************
I've tried several different solutions, and can't get past this 401 error.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search