带有凭据的Web浏览器 [英] Webbrowser with Credentials

查看:107
本文介绍了带有凭据的Web浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一台带有sqlserver2008re和报告服务的Windows2008r2服务器.
在另一个站点上是我在客户端上的wpf应用程序,我想在Webbrowser-control中显示我的报告.
一切正常.但是还有一个问题,当我通过url"http://myserver/reportserver/myreport"调用报告时必须登录

有没有办法将网络凭证与webbrowser控件一起使用来进行自动登录?我不想让用户通知仍然存在登录,因此必须在后台完成.

感谢您的快速答复

doriath21

Hi guys,

i have an windows2008r2 server with sqlserver2008re and reporting services.
On the other site is my wpf-applictation on a client where i want to show my reports in a webbrowser-control.
Everything works fine. But ther is still the problem, that i have to login when i call the report through the url "http://myserver/reportserver/myreport"

Is there a way to use networkcredentials together with the webbrowser control for autologin? I don''t want that the user notifies that there is a login anyway so it must be done in background.

Thanks for your fast replies

doriath21

推荐答案

我已经尝试过使用HttpWebRequest这样的方法.
I already did tried to use HttpWebRequest like this.
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(@"http://myserver/reportserver/myreport");
request.Credentials = new NetworkCredential("user", "password");
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
browser.NavigateToStream(response.GetResponseStream());



但是因为那是大量的脚本错误而无法正常工作



But Didn''t work becaus ther are tons of script-errors


现在我将报告服务器的授权从Ntlm更改为Basic,因此我可以通过附加的标头插入我的登录信息den webbrowser.Navigate-method.
但是登录弹出窗口仍然发生...

Now i changed the authorization from the Reportserver from Ntlm to Basic...there i can insert my logininformation by aditional headers in den webbrowser.Navigate-method.
But the login-popup still occurs...

byte[] authData = System.Text.UnicodeEncoding.UTF8.GetBytes("user: password");
string authHeader = "Authorization: Basic " + Convert.ToBase64String(authData) + "\r\n";
browser.Navigate(uri, "", null, authHeader);



还有其他想法吗?



Any other idears?


您可以使用HttpWebRequest对象将凭据发布到幕后. Google是您的朋友.
You can use a HttpWebRequest object to post the credentials behind the scenes. Google is your friend.


这篇关于带有凭据的Web浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆