WPF启动浏览器凭据 [英] WPF Launch Browser with Credentials

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

问题描述

我使用WPF和C#。

我希望能够推出一个浏览器窗口,最有可能的IE浏览器,并提供已知的凭据,以便基于Windows的应用程序可以处理到外部浏览器从自身的转变,而无需用户再次输入他/她的凭据。

I want to be able to launch a browser window, most likely IE, and provide known credentials so that the Windows-based application can handle the transition from itself to an outside browser without having the user enter his/her credentials again.

我不知道如何启动浏览器:

I do know how to launch the browser:

System.Diagnostics.Process.Start(url);

我的主要问题是,我怎么能附上身份验证呢?也许通过某种方式将头呢?

My main question is, how can I attach authentication to that? Perhaps by adding headers to it somehow?

最后,我真的不希望使用新的WebBrowser控件WPF里面,由于它的当前问题与一个透明的窗口中显示。

Lastly, I don't really want to use the new WebBrowser control inside of WPF due to it's current problems with displaying with a transparent window.

推荐答案

1),你必须知道如何登录。
   要手动做到这一点登录的Web应用程序和微量元素与HTTP调试像小提琴手的HTTP流量。注意发送什么样的http请求,什么名称的参数等。
一旦你知道有什么序列HTTP请求被发送到登录你有浏览器做到这一点。

1) You have to know how to "log in". To do this login manually in the web application and trace the http traffic with http debugger like Fiddler. Pay attention what kind of http requests are sent, what names have the parameters, etc. Once you know what sequence of http requests has to be send to log in you has to do this with the browser.

2)实现自动登录
2.1)万一登录通过HTTP GET发生 - 只是追加正确的查询字符串的URL并启动浏览器。如果你控制了Web应用程序和建立在这种机制这一只可能发生,其他明智的日志中的POST以https。几乎总是执行

2) Implement log in automatically 2.1) If by any chance log in happens via http GET - just append the right query string to the url and start the browser. This could happen only if you control the web application and build in this mechanism, other wise log in is almost always implemented as POST with https.

2.2),如果你要做的POST请求,你有几种选择:
2.2.1),你可以提供本地的HTML文档,包含的JavaScript,使AJAX调用从JavaScript的登录表单。要通过你可以使用GET参数的参数。

2.2) If you have to do POST request you have several options: 2.2.1) You could provide local html document, that contains javascript and make ajax call to the login form from the javascript. To pass the parameters you could use get parameters.

2.2.2),如果没有别的工作,你将不得不通过COM使用的浏览器(WebBrowser控件)

2.2.2) If nothing else works you will have to use the browser via COM (WebBrowser control)

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

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