title: How to receive a http web request on a windows form application
body: <p>How can one pass http get or post methods to a windows application? I require a webserver to send a get method to my windows form application that will query a database then reply back to a webserver</p>
  
  <p>I'm developing a windows based search engine that searches a MySQL database. It receives a keyword from an SMS gateway software as a HTTP get request and should reply to the gateway software using the same HTTP request.This is my code. It is correctly searching the database but I don't know how to receive the get methods on the application however it's sending the messages to SMS gateway.</p>
  
  <pre><code>Private Sub bSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bSend.Click
      Dim request As HttpWebRequest
      Dim response As HttpWebResponse = Nothing
      Dim url As String
      Dim username As String = "admin"
      Dim password As String = "abc123"
      Dim host As String = "http://127.0.0.1:9501"
      Dim originator As String = "0724116972"
  
      Try
  
          url = host + "/api?action=sendmessage&amp;" _
                   &amp; "username=" &amp; HttpUtility.UrlEncode(username) _
                   &amp; "&amp;password=" + HttpUtility.UrlEncode(password) _
                   &amp; "&amp;recipient=" + HttpUtility.UrlEncode(tbReceiver.Text) _
                   &amp; "&amp;messagetype=SMS:TEXT" _
                   &amp; "&amp;messagedata=" + HttpUtility.UrlEncode(tbMessage.Text) _
                   &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)
  
      Catch ex As Exception
          MessageBox.Show("Error. Server Not running")
          Me.Close()
      End Try
    End Sub
  End Class
  </code></pre>