none
Embed paginated reports into ASP.NET web apps using the Report Viewer control RRS feed

  • Question

  • Hi,

    I am getting an error when try to embed my report into a web page.

    This is my ASPX code:

    <%@ Page Title="" Language="C#" MasterPageFile="~/Layout.master" AutoEventWireup="true" CodeBehind="HomeReports.aspx.cs" Inherits="ProjectTrackerExtreme.Pages.HomeReports" %>

    <%@ Register assembly="Microsoft.ReportViewer.WebForms, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" namespace="Microsoft.Reporting.WebForms" tagprefix="rsweb" %>

    <asp:Content ID="Content1" ContentPlaceHolderID="Content" runat="server">
        <div id="gridContainer" style="height:70%; width:90%; margin: 0 auto">
            <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
            <rsweb:ReportViewer ID="rvReport" runat="server" ProcessingMode="Remote" Width="100%">
            </rsweb:ReportViewer> 
        </div>
    </asp:Content>

    and this is the server code:

    using System;
    using Microsoft.Reporting.WebForms;
    using System.Security.Principal;
    using System.Net;

    namespace ProjectTrackerExtreme.Pages
    {
        public partial class HomeReports : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                LoadReportByID(1);
            }

            private void LoadReportByID(int reportID)
            {
                rvReport.ProcessingMode = ProcessingMode.Remote;
                rvReport.ServerReport.ReportServerUrl = new Uri("http://ssrstest.proximagroup.com/Reports");
                rvReport.ServerReport.ReportServerCredentials = new ReportServerCredentials("<my account>", "<my password>", "<my domain>");
                rvReport.ServerReport.ReportPath = "/report/Rosario%20Web%20Portal%20Test";
                rvReport.ServerReport.Refresh();
            }
        }

        [Serializable]
        public class ReportServerCredentials : IReportServerCredentials
        {
            private string _userName;
            private string _password;
            private string _domain;

            public ReportServerCredentials(string userName, string password, string domain)
            {
                _userName = userName;
                _password = password;
                _domain = domain;
            }

            public WindowsIdentity ImpersonationUser
            {
                get
                {
                    // Use default identity.
                    return null;
                }
            }

            public ICredentials NetworkCredentials
            {
                get
                {
                    // Use default identity.
                    return new NetworkCredential(_userName, _password, _domain);
                }
            }

            public bool GetFormsCredentials(out Cookie authCookie, out string user, out string password, out string authority)
            {
                // Do not use forms credentials to authenticate.
                authCookie = null;
                user = password = authority = null;
                return false;
            }
        }
    }

    When the page is loaded, I am receiving the following error:

    • The request failed with HTTP status 403: Forbidden.

    Any idea? I am going to crazy... :)

    Thanks,

    Ros.

    • Moved by Gary Gallanes [HCL Technologies] Tuesday, May 16, 2017 2:49 PM Azure Stack is in Technical Preview. This post will be best supported in Visual Studio Forum
    • Moved by 宝宝徐 Thursday, May 18, 2017 1:43 AM
    Monday, May 15, 2017 2:21 PM

All replies