Article ID: 313068 - Last Review: May 13, 2007 - Revision: 5.6 How to host a WebBrowser control in Visual C# 2005 or in Visual C# .NET to post form dataThis article was previously published under Q313068
For a Microsoft Visual Basic .NET version of this article, see 311294
(http://support.microsoft.com/kb/311294/
)
.
On This PageSUMMARY This step-by-step article shows you how to use the WebBrowser ActiveX control in Microsoft Visual C# 2005 or in Microsoft
Visual C# .NET to perform a post of form data. Visual C# 2005 or Visual C# .NET can use the WebBrowser ActiveX control to send data by using the Post method to an HTTP server such as Microsoft Internet Information Server (IIS). For the purposes of performing a post, you can use the Navigate or Navigate2 method of the WebBrowser control, where only the URL, PostData, and Headers parameters are relevant. For more information about the other parameters and the Navigate2 method, visit the following Microsoft Web site:
Navigate2 Method 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 byte array, and the
Headers parameter must contain a string that contains the following HTTP
header: http://msdn.microsoft.com/en-us/library/aa752094(VS.85).aspx (http://msdn.microsoft.com/en-us/library/aa752094(VS.85).aspx)
Content-Type: application/x-www-form-urlencoded
This header indicates that the data being posted is encoded
according to HTML specifications.Note that the Internet Explorer Script Object Model has a Window object, which has a Navigate method as well. This Navigate method accepts only a URL and cannot be used to post data to a Web server. ASPXTo test the following sample code, the following Active Server Pages (.aspx) file should be saved to the Navpost.aspx file in a directory on IIS. The directory should be recognized by IIS as a virtual root with execute permissions for the scripts.Visual C# 2005 or Visual C# .NETTo demonstrate a Post method in C#, follow these steps:
REFERENCES
For more information, click the following article number to view the article in the Microsoft Knowledge Base:
174923
(http://support.microsoft.com/kb/174923/
)
How to use the PostData parameter in WebBrowser control
For more information about the WebBrowser control and the methods, properties, and events that it exposes,
visit the following Microsoft Web site: http://msdn2.microsoft.com/en-us/library/Aa752043.aspx
(http://msdn2.microsoft.com/en-us/library/Aa752043.aspx)
For the HTML specification for Form content types, visit the
following W3C Web site: http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.1
(http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.1)
For more
information about developing Web-based solutions for Microsoft Internet
Explorer, visit the following Microsoft Web sites:http://msdn2.microsoft.com/en-us/ie/default.aspx
(http://msdn2.microsoft.com/en-us/ie/default.aspx)
http://support.microsoft.com/iep (http://support.microsoft.com/iep) | Article Translations
|

Back to the top
