How send credentials using ReportViewerForMVC

SSRS-VS 46 Reputation points
2023-05-15T12:30:18.48+00:00

I want to see my reports in my asp.net MVC web project. For this task, I'm using the nugget extension: ReportViewerForMVC

SSRS server and the .net web project are in different computers:

This is my controller:

imagen

And this is the view:

imagen

And I'm getting this error:

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() +192 Microsoft.Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution.RSExecutionConnection.IsSecureMethod(String methodname) +51
Microsoft.Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution.RSExecutionConnection.SetConnectionSSLForMethod(String methodname) +12
Microsoft.Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution.ProxyMethodInvocation.Execute(RSExecutionConnection connection, ProxyMethod1 initialMethod, ProxyMethod1 retryMethod) +449 Microsoft.Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution.RSExecutionConnection.LoadReport(String Report, String HistoryID) +180
Microsoft.Reporting.WebForms.SoapReportExecutionService.LoadReport(String report, String historyId) +24
Microsoft.Reporting.WebForms.ServerReport.EnsureExecutionSession() +70 Microsoft.Reporting.WebForms.ServerReport.GetParameters() +54
ReportViewerForMvc.ReportViewerExtensions.SetProperties(ServerReport serverReport, ServerReport properties) +60
ReportViewerForMvc.ReportViewerExtensions.SetProperties(ReportViewer reportViewer, ReportViewer properties) +154
ReportViewerForMvc.ReportViewerWebForm.BuildReportViewer() +67
ReportViewerForMvc.ReportViewerWebForm.Page_Load(Object sender, EventArgs e) +5
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +52 System.Web.UI.Control.OnLoad(EventArgs e) +97
System.Web.UI.Control.LoadRecursive() +61
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +693

I think this is because of the credentials, so now I'm using this to send the credentials (I guess that domain parameter is the windows domain on the ssrs server pc, right?):

imagen

User's image

But I'm getting the error "empty respond":

Server error in application '/'.
The request failed with an empty response.
Description: Unhandled exception executing the current web request. Review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.WebException: Request failed with an empty response.

Source code error:

An unhandled exception was thrown during the execution of the current web request. Information about the source and location of the exception can be identified using the exception stack trace below.

Stack trace:


[WebException: Request failed with an empty response.]
   System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) +183224
   System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) +221
   Microsoft.Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution.ReportExecutionService.LoadReport3(String Report, String HistoryID) +63
   Microsoft.Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution.<>c__DisplayClass3.<LoadReport>b__0() +18
   Microsoft.Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution.ProxyMethodInvocation.Execute(RSExecutionConnection connection, ProxyMethod`1 sql16Method, ProxyMethod`1 katmaiMethod, ProxyMethod`1 yukonMethod) +566
   Microsoft.Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution.RSExecutionConnection.LoadReport(String Report, String HistoryID) +241
   Microsoft.Reporting.WebForms.SoapReportExecutionService.LoadReport(String report, String historyId) +24
   Microsoft.Reporting.WebForms.ServerReport.EnsureExecutionSession() +121
   Microsoft.Reporting.WebForms.ServerReport.GetParameters() +53
   ReportViewerForMvc.ReportViewerExtensions.SetProperties(ServerReport serverReport, ServerReport properties) +60
   ReportViewerForMvc.ReportViewerExtensions.SetProperties(ReportViewer reportViewer, ReportViewer properties) +154
   ReportViewerForMvc.ReportViewerWebForm.BuildReportViewer() +67
   ReportViewerForMvc.ReportViewerWebForm.Page_Load(Object sender, EventArgs e) +5
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +52
   System.Web.UI.Control.OnLoad(EventArgs e) +97
   System.Web.UI.Control.LoadRecursive() +61
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +693

I need help.

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,362 questions
SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
2,849 questions
{count} votes

3 answers

Sort by: Most helpful
  1. AniyaTang-MSFT 12,341 Reputation points Microsoft Vendor
    2023-05-16T01:55:08.2833333+00:00

    Hi @SSRS-VS

    I don't know much about asp.net, about SSRS authentication, you can refer to this link: https://learn.microsoft.com/en-us/sql/reporting-services/extensions/security-extension/authentication-in-reporting-services?view=sql-server-ver16.

    Best regards,

    Aniya

    1 person found this answer helpful.
    0 comments No comments

  2. Ken Taylor 5 Reputation points
    2023-11-07T23:51:02.7133333+00:00

    From what I can tell, all the code above is correct. I implemented pretty much the same code you listed; however, it took me a couple of tries to get things working correctly, and it basically came down to the username, password, and domain name used when creating the CustomReportCredentials. Here are the basics:

    1. First you must have a user, which can also be a local account on the server hosting the Report Server or a domain user account if using Active Directory (AD).
    2. That user must be added and given the "Browse" role on the report directory for which you want them to view the report. This is important. You will find it under "Manage Folder" -> "Security".
    3. You then use that user's username as the "username" field, their password as the "password.
    4. You then enter domain name. For a local account it would the the server (or PC's) name like "myReportServerHost" or whatever. For an AD user it would be the AD domain name like "myAD" or whatever. This was the trickiest part for me, and apparently for others as well based on other articles.

    So the take away is:

    1. Implement the IReportServerCredentials class as you have done above.
    2. Set the appropriate username, password, and domain name.
    3. Add the user, if not already present, to the report server's report directory where the report resides, and configure with a minimum of the browse role.
    4. That should do it.

    I hope someone else finds this useful.

    1 person found this answer helpful.
    0 comments No comments

  3. Bruce (SqlWork.com) 59,046 Reputation points
    2023-11-08T17:16:23.0433333+00:00

    if you are going to use a common login, then just change the app pool account to a domain account. then give this account the required permissions.

    if you want to use the browser user account then use basic or kerberos authentication.

    0 comments No comments