Article ID: 311293 - Last Review: July 30, 2003 - Revision: 2.0 HOW TO: Automate Internet Explorer to POST Form DataThis article was previously published under Q311293 On This PageSUMMARY An automation
controller, such as Microsoft Visual Basic, can automate Microsoft Internet
Explorer to send data by using the POST method to an HTTP server (such as
Microsoft Internet Information Services [IIS]). This article explains how to
automate Internet Explorer to perform a POST of form data from a Visual Basic
.NET application. Although the examples illustrate automation of the whole
Internet Explorer application, the same techniques can be applied to the Web
Browser ActiveX control when it is hosted in an application. More InformationSeveral methods are available for sending data to an HTTP server. GET and POST are currently the most common two. POST is typically used to submit form data to an HTTP server when that data exceeds the maximum allowable transfer limit on the GET method. This limit is typically 2 kilobytes (KB).Internet Explorer exposes the IWebBrowser(App) interface to automation controllers. The IWebBrowser(App) interface has a Navigate method. In Interface Definition Language (IDL) syntax (a universal representation from which both the Visual Basic and Visual C++ syntax is derived), the Navigate method looks like the following: To call Navigate and POST form data to an HTTP server, the URL parameter must specify a valid address, the PostData parameter must contain a SAFEARRAY of bytes, and the Headers parameter must contain a BSTR that contains the following HTTP header:
Content-Type: application/x-www-form-urlencoded
This header indicates that the data being posted is encoded
according to the rules specified in the HTML specification.Note that the Internet Explorer Script Object Model window object has a navigate method as well. This navigate method will only accept a URL and cannot be used to POST data to a Web server. Steps to Implement Technique
REFERENCESFor additional information about how to use WinInet to simulate a form POST request, click the article number below to view the article in the Microsoft Knowledge Base:165298
(http://support.microsoft.com/kb/165298/EN-US/
)
HOW TO: Simulate a Form POST Request Using WinInet
For additional information about how to
use a URL Moniker to simulate a form POST request, click the article number
below to view the article in the Microsoft Knowledge Base: 165800
(http://support.microsoft.com/kb/165800/EN-US/
)
PostMon.exe Demonstrates How to Use URL Moniker to POST Data
311294
(http://support.microsoft.com/kb/311294/EN-US/
)
HOW TO: Host a WebBrowser Control in Visual Basic .NET to Post Form Data
| Article Translations
|
Back to the top
