Error al renderizar informes de PowerBI con ReportViewer

Un usuario Pregunto ✅

dibujar

Hola a todos,

Estoy probando algunas formas de incrustar informes de Power BI que se almacenan en Power BI Report Server y estoy desarrollando una página web en asp.net para ver un informe.

Me conecté con éxito a mis informes, creo, pero aparece el mensaje «Solicitud fallida con respuesta vacía» cuando recibo el informe.

Todo está bien cuando me conecto directamente en el navegador del portal.

¿Tienes algunas ideas sobre este?

encontrar clase asp

using Microsoft.Reporting.WebForms;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Net;
using System.Security.Principal;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ReportViewer_PowerBI
{
    public partial class WebForm1 : System.Web.UI.Page
    {

        private String username;
        private String pwd;
        private String report;

        protected void Page_Load(object sender, EventArgs e)
        {
            ReportViewer1.ProcessingMode = ProcessingMode.Remote;
        }


        protected void Button1_Click(object sender, EventArgs e)
        {
            username = this.txtUser.Text;
            pwd = this.txtPassword.Text;
            report = this.txtReport.Text;

            ReportViewer1.Reset();
            ReportViewer1.ServerReport.ReportServerCredentials = new CustomReportCredentials(username, pwd, "XX");
            ReportViewer1.ServerReport.ReportServerUrl = new Uri("http://myReport");
            ReportViewer1.ServerReport.ReportPath = "https://community.powerbi.com/" + report;

            //ReportViewer1.ServerReport.Refresh();

        }
    }

    /// 
    /// Summary description for CustomReportCredentials
    /// 
    public class CustomReportCredentials :
    Microsoft.Reporting.WebForms.IReportServerCredentials
    {

        // local variable for network credential.
        private string _UserName;
        private string _PassWord;
        private string _DomainName;
        public CustomReportCredentials(string UserName, string PassWord,
    string DomainName)
        {
            _UserName = UserName;
            _PassWord = PassWord;
            _DomainName = DomainName;
        }
        public WindowsIdentity ImpersonationUser
        {
            get
            {
                return null;  // not use ImpersonationUser
            }
        }
        public ICredentials NetworkCredentials
        {
            get
            {

                // use NetworkCredentials
                return new NetworkCredential(_UserName,
    _PassWord, _DomainName);
            }
        }
        public bool GetFormsCredentials(out Cookie authCookie,
    out string user, out string password, out string authority)
        {

            // not use FormsCredentials unless you have 
            //implements a custom autentication.
        authCookie = null;
            user = password = authority = null;
            return false;
        }
    }
}

Y también formulario web

<body>
    <form id="form1" runat="server">
        
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <rsweb:ReportViewer ID="ReportViewer1" runat="server" ProcessingMode="Remote" Height="297px">
                <ServerReport />
        </rsweb:ReportViewer>
        
        <p>
            User<asp:TextBox ID="txtUser" runat="server"></asp:TextBox>
        </p>
        <p id="txtPwd">
            Password<asp:TextBox ID="txtPassword" runat="server" style="margin-bottom: 0px"></asp:TextBox>
        </p>
        <p>
            Report<asp:TextBox ID="txtReport" runat="server" style="margin-bottom: 4px"></asp:TextBox>
        </p>
        <p>
            <asp:Button ID="btnVal" runat="server" OnClick="Button1_Click" Text="Load" />
        </p>
        
    </form>
</body>

Gracias

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *