IWebBrowserApp.Navigate() 如何发送Post数据
如果有人可以向我展示如何使用导航方法发送 POST 数据的好示例(可通过 SHDocVw.IWebBrowserApp
获取),我将非常高兴。
考虑例如。
我们应该去的页面是:http://example.com/check.php
并且应该发送两个输入字段的值:用户名和密码。
编辑
我正在尝试使用我的 C# 应用程序使用 Windows 操作系统上可用的本机 Internet Explorer 版本 7 或更高版本,将 HTTP 请求发送到特定 URL,使用 POST 方法传递用户名和将用户密码发送到处理 HTTP 响应的服务器端页面。
使用 IWebBrowserApp
和 Navigate
方法,我可以打开 Internet Explorer 的新窗口/实例并将其发送到特定页面(本地或网络中),并且如果指定,还发送 POST 数据和自定义标头。
但主要问题是我不知道如何将数据写入浏览器携带的 POST 请求中。
我将不胜感激的帮助。
I would be very glad if someone could show me a good example of how to send POST data with the Navigate Method, available through SHDocVw.IWebBrowserApp
.
Considering for example.
That the page were we should go is: http://example.com/check.php
And should send the values of two input fields named: username and password.
EDIT
I'm attempting with my C# App to use the native Internet Explorer version 7 or higher, available on Windows OS, to send a HTTP Request to a specific URL, passing using the POST method the username and password of an user to a server side page that would handle the HTTP Response.
With IWebBrowserApp
and the Navigate
method I'm able to open a new window/instance of Internet Explorer and send it to a specific page (local or in the web), and if specified also send POST data and custom headers.
But the main problem its that i don't know how to write my data into a POST request to be carried by the browser.
I would appreciate help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经找到了如何命令 IE 打开网页并发送一些 POST 数据。
将名为 Microsoft Internet Explorer Controls 的 COM 引用添加到项目中。 p>
然后创建
post 字符串
,其中字段及其值以&
分隔,然后将该字符串
转换为字节数组
。最后只需请求 IE 导航到
url
,并将 Post Data 转换为字节数组
发送,然后添加相同的 Header它是在我们提交表单时添加的。这里是:
注意:
尝试一下这是否有效。不要忘记您的服务器端页面必须写入/回显名为:用户名和密码的帖子字段。
PHP 代码示例:
ASP 代码示例:
页面将显示如下内容:
I've found how to order IE to open a webpage and send some POST data.
Add a COM Reference named Microsoft Internet Explorer Controls to the project.
Then create the
post string
with the field and its value separated by&
, and then convert thatstring
into abyte array
.And in the end just had to request IE to Navigate to the
url
, and also send the Post Data converted into abyte array
, and then add the same Header that its added when we submit a form.Here goes:
NOTE:
To try if this works. Don't forget that your server side page would have to write/echo the Post fields named: username and password.
PHP Code Example:
ASP Code Example:
And the page would display something like this: