<legend id='8lJ0U'><style id='8lJ0U'><dir id='8lJ0U'><q id='8lJ0U'></q></dir></style></legend>

    <i id='8lJ0U'><tr id='8lJ0U'><dt id='8lJ0U'><q id='8lJ0U'><span id='8lJ0U'><b id='8lJ0U'><form id='8lJ0U'><ins id='8lJ0U'></ins><ul id='8lJ0U'></ul><sub id='8lJ0U'></sub></form><legend id='8lJ0U'></legend><bdo id='8lJ0U'><pre id='8lJ0U'><center id='8lJ0U'></center></pre></bdo></b><th id='8lJ0U'></th></span></q></dt></tr></i><div id='8lJ0U'><tfoot id='8lJ0U'></tfoot><dl id='8lJ0U'><fieldset id='8lJ0U'></fieldset></dl></div>

  1. <small id='8lJ0U'></small><noframes id='8lJ0U'>

      <tfoot id='8lJ0U'></tfoot>

        <bdo id='8lJ0U'></bdo><ul id='8lJ0U'></ul>
    1. 嵌入 Power Bi Report Promise 未定义 powerbi.js

      时间:2023-08-28
        <tbody id='blR9Z'></tbody>

      <small id='blR9Z'></small><noframes id='blR9Z'>

        <bdo id='blR9Z'></bdo><ul id='blR9Z'></ul>
          <tfoot id='blR9Z'></tfoot>
        1. <i id='blR9Z'><tr id='blR9Z'><dt id='blR9Z'><q id='blR9Z'><span id='blR9Z'><b id='blR9Z'><form id='blR9Z'><ins id='blR9Z'></ins><ul id='blR9Z'></ul><sub id='blR9Z'></sub></form><legend id='blR9Z'></legend><bdo id='blR9Z'><pre id='blR9Z'><center id='blR9Z'></center></pre></bdo></b><th id='blR9Z'></th></span></q></dt></tr></i><div id='blR9Z'><tfoot id='blR9Z'></tfoot><dl id='blR9Z'><fieldset id='blR9Z'></fieldset></dl></div>

              <legend id='blR9Z'><style id='blR9Z'><dir id='blR9Z'><q id='blR9Z'></q></dir></style></legend>

              • 本文介绍了嵌入 Power Bi Report Promise 未定义 powerbi.js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我创建了一个 power bi 报告.我想将此报告嵌入到我的 MVC 站点.这是我的代码:-

                私有静态只读字符串 ClientID = ConfigurationManager.AppSettings["ClientID"];私有静态只读字符串 ClientSecret = ConfigurationManager.AppSettings["ClientSecret"];私有静态只读字符串 RedirectUrl = ConfigurationManager.AppSettings["RedirectUrl"];私有静态只读字符串 AADAuthorityUri = ConfigurationManager.AppSettings["AADAuthorityUri"];私有静态只读字符串 PowerBiAPI = ConfigurationManager.AppSettings["PowerBiAPI"];私有静态只读字符串 PowerBiDataset = ConfigurationManager.AppSettings["PowerBiDataset"];私有静态只读字符串 baseUri = PowerBiDataset;私有静态字符串 accessToken = string.Empty;公共字符串GetAccessToken(字符串authorizationCode,字符串clientID,字符串clientSecret,字符串redirectUri){令牌缓存 TC = 新令牌缓存();字符串权限 = AADAuthorityUri;AuthenticationContext AC = new AuthenticationContext(authority, TC);ClientCredential cc = new ClientCredential(clientID, clientSecret);返回 AC.AcquireTokenByAuthorizationCodeAsync(授权码,新的 Uri(redirectUri), cc).Result.AccessToken;}公共无效GetAuthorizationCode(){var @params = 新的 NameValueCollection{{"response_type", "code"},{"client_id", ClientID},{"资源", PowerBiAPI},{ "redirect_uri", RedirectUrl}};var queryString = HttpUtility.ParseQueryString(string.Empty);queryString.Add(@params);Response.Redirect(String.Format(AADAuthorityUri + "?{0}", queryString));}公共行动结果索引(){if (Request.QueryString["code"] != null){会话["AccessToken"] = GetAccessToken(HttpContext.Request["code"],客户 ID,客户秘密,重定向网址);}if (Session["AccessToken"] != null){accessToken = Session["AccessToken"].ToString();System.Net.WebRequest 请求 = System.Net.WebRequest.Create(String.Format("{0}/Reports",baseUri)) 作为 System.Net.HttpWebRequest;request.Method = "GET";request.ContentLength = 0;request.Headers.Add("授权", String.Format("Bearer {0}", accessToken));使用 (var response = request.GetResponse() as System.Net.HttpWebResponse){使用 (var reader = new System.IO.StreamReader(response.GetResponseStream())){PBIReports 报告 = JsonConvert.DeserializeObject(reader.ReadToEnd());if (Reports.value.Length > 0){PBIReport 报告 = Reports.value[13];返回视图(报告);}}}}获取授权码();返回视图();}

                在重定向到this"时,它适用于 power bi 登录页面,在我登录后它会重定向回此页面(因为主页和重定向 url 相同).获取所有报告数据后,一段时间后出现错误消息,指出 http://localhost:34244/Scripts/powerbi.js 中第 5153 行第 11 列的 Unhandled exception0x800a1391 - JavaScript 运行时错误:'Promise' 未定义

                然后它说

                 在 https://app.powerbi.com/13.0.1781.272/scripts/powerbiportal.dependencies.externals.bundle.min.js 的第 1236 行第 335 列引发异常0x80070005 - JavaScript 运行时错误:访问被拒绝.如果有这个异常的处理程序,程序可以安全地继续.在 https://app.powerbi.com/13.0.1781.272/scripts/powerbiportal.common.bundle.min.js 的第 42 行第 17057 列引发异常0x80070005 - JavaScript 运行时错误:访问被拒绝.如果有这个异常的处理程序,程序可以安全地继续.

                然后它又开始再次显示第一条错误消息.

                这是我的 index.cshtml

                <代码>@{ViewBag.Title = "索引";布局 = "~/Views/Shared/_ColumnsOne.cshtml";}<script src="~/Scripts/powerbi.js"></script><脚本类型="文本/javascript">window.onload = 函数(){var accessToken = "@Session["AccessToken"].ToString()";if (!accessToken || accessToken == ""){返回;}var embedUrl = "@Model.embedUrl";var reportId = "@Model.id";变量配置 = {类型:'报告',访问令牌:访问令牌,嵌入网址:嵌入网址,id:reportId,设置:{filterPaneEnabled:假,导航内容窗格启用:假}};常量过滤器 = {$schema: "http://powerbi.com/product/schema#basic",目标: {表:查询1",栏目:学号"},运算符:在",值:[10"]};var reportContainer = document.getElementById('reportContainer');var report = powerbi.embed(reportContainer, config);report.on("加载", function () {var logView = document.getElementById('logView');logView.innerHTML = logView.innerHTML + "已加载<br/>";report.off("加载");});report.on("渲染", function () {var logView = document.getElementById('logView');logView.innerHTML = logView.innerHTML + "渲染<br/>";report.off("渲染");});report.setFilters([过滤器]).then(函数(结果){日志.log(结果);}).catch(函数(错误){日志.log(错误);});};</脚本>

                <div ID="reportContainer" style="width: 900px; height: 550px"></div></div>

                解决方案

                IE 还不支持 Promise.您可以通过包含外部库来启用支持.请在此处查看 Microsoft 关于 Power BI 的评论 - 支持 IE8 和 Promises?

                我在 IE11 上遇到了同样的问题,这个建议奏效了!希望对你也有帮助.

                I have created a power bi report. I want to embed this report to my MVC site. Here is my code:-

                private static readonly string ClientID = ConfigurationManager.AppSettings["ClientID"];
                private static readonly string ClientSecret = ConfigurationManager.AppSettings["ClientSecret"];
                private static readonly string RedirectUrl = ConfigurationManager.AppSettings["RedirectUrl"];
                private static readonly string AADAuthorityUri = ConfigurationManager.AppSettings["AADAuthorityUri"];
                private static readonly string PowerBiAPI = ConfigurationManager.AppSettings["PowerBiAPI"];
                private static readonly string PowerBiDataset = ConfigurationManager.AppSettings["PowerBiDataset"];
                 private static readonly string baseUri = PowerBiDataset;
                 private static string accessToken = string.Empty;
                
                 public string GetAccessToken(string authorizationCode, string clientID, string clientSecret, string redirectUri)
                        {      
                            TokenCache TC = new TokenCache();
                            string authority = AADAuthorityUri;
                            AuthenticationContext AC = new AuthenticationContext(authority, TC);
                            ClientCredential cc = new ClientCredential(clientID, clientSecret);
                            return AC.AcquireTokenByAuthorizationCodeAsync(
                                authorizationCode,
                                new Uri(redirectUri), cc).Result.AccessToken;
                        }
                
                        public void GetAuthorizationCode()
                        {
                            var @params = new NameValueCollection
                            {
                                {"response_type", "code"},
                                {"client_id", ClientID},
                                {"resource", PowerBiAPI},
                                { "redirect_uri", RedirectUrl}
                            };
                
                            var queryString = HttpUtility.ParseQueryString(string.Empty);
                            queryString.Add(@params);
                            Response.Redirect(String.Format(AADAuthorityUri + "?{0}", queryString));
                        }
                
                        public ActionResult Index()
                        {
                            if (Request.QueryString["code"] != null)
                            {
                                Session["AccessToken"] = GetAccessToken(
                                    HttpContext.Request["code"],
                                    ClientID,
                                    ClientSecret,
                                    RedirectUrl);
                            }
                            if (Session["AccessToken"] != null)
                            {
                                accessToken = Session["AccessToken"].ToString();
                                System.Net.WebRequest request = System.Net.WebRequest.Create(
                                 String.Format("{0}/Reports",
                                 baseUri)) as System.Net.HttpWebRequest;
                
                                request.Method = "GET";
                                request.ContentLength = 0;
                                request.Headers.Add("Authorization", String.Format("Bearer {0}", accessToken));
                                using (var response = request.GetResponse() as System.Net.HttpWebResponse)
                                {
                                    using (var reader = new System.IO.StreamReader(response.GetResponseStream()))
                                    {
                                        PBIReports Reports = JsonConvert.DeserializeObject<PBIReports>(reader.ReadToEnd());
                                        if (Reports.value.Length > 0)
                                        {
                                            PBIReport report = Reports.value[13];
                                            return View(report);
                                        }
                                    }
                                }
                            }
                            GetAuthorizationCode();
                            return View();
                        }
                

                On Redirecting to "this", it goes for power bi login page and after I sign in it redirects back to this page (as homepage and redirect url are same). After getting all the report data, after some time a error message comes up saying Unhandled exception at line 5153, column 11 in http://localhost:34244/Scripts/powerbi.js 0x800a1391 - JavaScript runtime error: 'Promise' is undefined

                After that it says

                 Exception was thrown at line 1236, column 335 in https://app.powerbi.com/13.0.1781.272/scripts/powerbiportal.dependencies.externals.bundle.min.js
                
                0x80070005 - JavaScript runtime error: Access is denied.
                
                If there is a handler for this exception, the program may be safely continued.
                
                Exception was thrown at line 42, column 17057 in https://app.powerbi.com/13.0.1781.272/scripts/powerbiportal.common.bundle.min.js
                
                0x80070005 - JavaScript runtime error: Access is denied.
                
                If there is a handler for this exception, the program may be safely continued.
                

                And then again it starts Showing the first error message again.

                Here is my index.cshtml

                @{
                    ViewBag.Title = "Index";
                    Layout = "~/Views/Shared/_ColumnsOne.cshtml";
                }
                <script src="~/Scripts/powerbi.js"></script>
                <script type="text/javascript">
                
                
                    window.onload = function () {
                        var accessToken = "@Session["AccessToken"].ToString()";
                
                        if (!accessToken || accessToken == "")
                        {
                            return;
                        }
                
                        var embedUrl = "@Model.embedUrl";
                        var reportId = "@Model.id";
                
                        var config = {
                            type: 'report',
                            accessToken: accessToken,
                            embedUrl: embedUrl,
                            id: reportId,
                            settings: {
                                filterPaneEnabled: false,
                                navContentPaneEnabled: false
                            }
                        };
                
                        const filter = {
                            $schema: "http://powerbi.com/product/schema#basic",
                            target: {
                                table: "Query1",
                                column: "SchoolID"
                            },
                            operator: "In",
                            values: ["10"]
                        };
                        var reportContainer = document.getElementById('reportContainer');
                
                
                        var report = powerbi.embed(reportContainer, config);
                
                        report.on("loaded", function () {
                            var logView = document.getElementById('logView');
                            logView.innerHTML = logView.innerHTML + "Loaded<br/>";
                
                            report.off("loaded");
                        });
                        report.on("rendered", function () {
                            var logView = document.getElementById('logView');
                            logView.innerHTML = logView.innerHTML + "Rendered<br/>";
                
                            report.off("rendered");
                        });
                        report.setFilters([filter])
                        .then(function (result) {
                            Log.log(result);
                        })
                        .catch(function (errors) {
                            Log.log(errors);
                        });
                    };
                </script>
                
                <div>
                   <div ID="reportContainer" style="width: 900px; height: 550px"></div>
                </div>
                

                解决方案

                IE does not yet support Promise. You can enable support by including an external library. Please see Microsoft's comments on this in relation to Power BI here - Support for IE8 and Promises?

                I had the same issue with IE11 and the suggestion worked! Hope it helps you too.

                这篇关于嵌入 Power Bi Report Promise 未定义 powerbi.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:PBI (Power BI) 服务不支持的 System.Object 类型 下一篇:电源报告嵌入的未经授权的错误 401

                相关文章

                最新文章

                <tfoot id='HVPXl'></tfoot>
              • <i id='HVPXl'><tr id='HVPXl'><dt id='HVPXl'><q id='HVPXl'><span id='HVPXl'><b id='HVPXl'><form id='HVPXl'><ins id='HVPXl'></ins><ul id='HVPXl'></ul><sub id='HVPXl'></sub></form><legend id='HVPXl'></legend><bdo id='HVPXl'><pre id='HVPXl'><center id='HVPXl'></center></pre></bdo></b><th id='HVPXl'></th></span></q></dt></tr></i><div id='HVPXl'><tfoot id='HVPXl'></tfoot><dl id='HVPXl'><fieldset id='HVPXl'></fieldset></dl></div>
              • <small id='HVPXl'></small><noframes id='HVPXl'>

                  <legend id='HVPXl'><style id='HVPXl'><dir id='HVPXl'><q id='HVPXl'></q></dir></style></legend>

                    • <bdo id='HVPXl'></bdo><ul id='HVPXl'></ul>