• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 882
  • Last Modified:

ASP.net VB.net post a string to an http server using some kind of http client using post method


In ASP.net VB.net how do I post a string to an http server using the post method. I was given the following link which helped but I still can't get my head around how to do this.
The java code below is an example of what I need to do in VB.net


  try {

      // This will Post the xml string data...    
      URL url = new URL("http://IPAddress:Port/APIWebModule/APIServlet");
      HttpURLConnection connection = (HttpURLConnection)url.openConnection();
      PrintWriter out = new PrintWriter( connection.getOutputStream());
      String data = "The XML string request";

      // This will read the XML response data...
      InputSource inSource = new InputSource(connection.getInputStream());
      DOMParser dp = new DOMParser();
      Document doc = dp.getDocument();
      // This gives you an XML DOM document to work with
    catch (SAXException ex) {
    catch (MalformedURLException ex) {
    catch (IOException ex) {
Murray Brown
Murray Brown
1 Solution
käµfm³d 👽Commented:
Why not just use the WebClient class? There is the UploadString method which sounds like what you are trying to do:

Dim data As String = "The XML string request"
Dim serverResponseHTML As String

Using wc As New System.Net.WebClient()
    serverResponseHTML = wc.UploadString("http://IPAddress:Port/APIWebModule/APIServlet", data)
End Using

Open in new window

Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks very much. I'll give that a try

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now