通过dotnet应用程序访问pentaho而无需通过URL

时间:2016-03-29 14:41:50

标签: c# asp.net iframe pentaho pentaho-cde

目前我正在将pentaho网址传递给iframe。但是,执行此操作时会显示用户名和密码。我的最终目标是弄清楚如何通过iframe发送请求并在没有网址的情况下打开iframe中的pentaho仪表板,或找出隐藏浏览器中凭据的方法。

Aspx页面

<iframe class="dashborad_content" src="<%= dashboardUrl %>"></iframe>

Aspx.cs页面

public string dashboardUrl = ConfigurationManager.AppSettings["dashboard"];

public async void getInfo()
    {
        var credentials = new NetworkCredential("admin", "password");
        var handler = new HttpClientHandler { Credentials = credentials };
        using (var client = new HttpClient(handler))
        {
            client.BaseAddress = new Uri(dashboardUrl);
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/html"));
            var content = new FormUrlEncodedContent(new[]
            {
                new KeyValuePair<string, string>("output-type", "PDF"),
                new KeyValuePair<string, string>("show_discontinue", "false")
            });
            System.Net.Http.HttpResponseMessage response = await client.PostAsync(dashboardUrl, content);

            if (!response.IsSuccessStatusCode)
            {
                throw new Exception();
            }


        }
    }

0 个答案:

没有答案