title: Read Post Data submitted to A HTML Form
body: <p>I've written my HTML webserver in VB.NET and I don't know how to make it read data values submitted in HTML forms. Please help me My web server only responds to HTTP 'GET' requests. My sample cod is below it is reading the URL rather tan the data contained in the forms`</p>
  
  <pre><code>    ' Extract path and filename from request
      sRequest = sbuffer.Substring(0, iStartPos - 1)
      sRequest.Replace("\\", "/")
      If ((sRequest.IndexOf(".") &lt; 1) AndAlso (Not sRequest.EndsWith("/"))) Then
          sRequest = sRequest &amp; "/"
      End If
  
      iStartPos = sRequest.LastIndexOf("/") + 1
  
      ' Get the filename
      sRequestedFile = sRequest.Substring(iStartPos)
  
      ' Get the relative path
      sDirName = sRequest.Substring(sRequest.IndexOf("/"), sRequest.LastIndexOf("/") - 3)
  
      ' Web server root path
      sLocalDir = sMyWebServerRoot
  
      ' if no filename specified
      ' look for default file
      If (sRequestedFile.Length = 0) Then
          sRequestedFile = _DefaultPage
          sPhysicalFilePath = sLocalDir &amp; sDirName &amp; sRequestedFile
  
          ' if no default file and no directory requested
          ' then show welcome page
          If Not File.Exists(sPhysicalFilePath) AndAlso (sDirName = "" OrElse sDirName = "/") Then
              'sErrorMessage = "&lt;H2&gt;MONITOR BUSINESS DIRECTORY SEARCH ENGINE SERVER&lt;BR&gt;"
              'sErrorMessage = sErrorMessage &amp; "&lt;BR&gt;"
              'sErrorMessage = sErrorMessage &amp; "&lt;BR&gt;&lt;BR&gt;Edit Config.ini and setup the default web path and default page.&lt;/H2&gt;"
              'SendHeader(sHttpVersion, "", sErrorMessage.Length, " 404 Not Found")
              'SendToBrowser(sErrorMessage)
  
              Dim tbReceiver, tbMessage As String
              tbReceiver = "aaaaaaaaaaaaaa"
              tbMessage = "cccccccccccccccc"
  
              Try
                  'mySender = Context.Request.QueryString("sender").ToString
                  request.
                  url = host + "/api?action=sendmessage&amp;" _
                           &amp; "username=" &amp; HttpUtility.UrlEncode(username) _
                           &amp; "&amp;password=" + HttpUtility.UrlEncode(password) _
                           &amp; "&amp;recipient=" + HttpUtility.UrlEncode(tbReceiver.ToString) _
                           &amp; "&amp;messagetype=SMS:TEXT" _
                           &amp; "&amp;messagedata=" + HttpUtility.UrlEncode(tbMessage.ToString) _
                           &amp; "&amp;originator=" + HttpUtility.UrlEncode(originator) _
                           &amp; "&amp;serviceprovider=" _
                           &amp; "&amp;responseformat=html"
  
  
                  request = DirectCast(WebRequest.Create(url), HttpWebRequest)
  
                  'response = DirectCast(request.GetResponse(), HttpWebResponse)
  
                  'MessageBox.Show("Response: " &amp; response.StatusDescription)
                  MessageBox.Show("Message has been passed to the server for sending")
  
              Catch ex As Exception
                  MessageBox.Show("Error. Server Not running")
              End Try
  
  
              mySocket.Close()
              Return
          End If
  
  
      End If
  
      ' get the mime type for the requested file
      Dim sMimeType As String = GetMimeType(sRequestedFile)
      If sMimeType = "" Then
          ' unknown type
          mySocket.Close()
          Return
      End If
      ' Build the complete path to the files
      sPhysicalFilePath = sLocalDir &amp; sDirName &amp; sRequestedFile
      ' Log("Request for file: " &amp; sPhysicalFilePath)
      If Not File.Exists(sPhysicalFilePath) Then
          ' File does not exist
          sErrorMessage = "&lt;H2&gt;404 Error! File Does Not Exist...&lt;/H2&gt;"
          SendHeader(sHttpVersion, "", sErrorMessage.Length, " 404 Not Found")
          SendToBrowser(sErrorMessage)
      Else
          ' Create File Stream of filename
          Dim fs As FileStream = New FileStream(sPhysicalFilePath, FileMode.Open, FileAccess.Read, FileShare.Read)
          ' create reader
          Dim reader As BinaryReader = New BinaryReader(fs)
  
          ' Create byte array buffer
          Dim bytes As Byte()
          ReDim bytes(CInt(fs.Length))
  
          ' Read file into byte array
          bytes = reader.ReadBytes(CInt(fs.Length))
  
          ' Total length of file
          Dim totbytes As Integer = CInt(fs.Length)
  
          ' close the reader and file stream
          reader.Close()
          fs.Close()
  
          ' Send HTTP header
          SendHeader(sHttpVersion, sMimeType, totbytes, " 200 OK")
  
          ' Send File
          SendToBrowser(bytes)
      End If
  
      ' All done for this connection!
      mySocket.Close()`
  </code></pre>