Skip to content Skip to sidebar Skip to footer

How Can My Server Program Read The Variables Sent Using A HTTP 'GET' Request Method In VB.NET?

I have written server code in vb.Net. I want it to read to variables sent by another server's HTTP 'GET' request. For example the first server will send this URL http://localhost/s

Solution 1:

You can get them from the Context.Request.QueryString object:

mySender = Context.Request.QueryString("sender").ToString

This assumes the code you are running on your server is running under IIS. I notice the call is to a .PHP page and wonder how you are actually getting the url to the server running the VB code.

If this is simply processing the URL as a string, then the following should handle it for you:

        Dim tempArray As String()
    Dim tempValuePairs As String()
    Dim tempPair As String()
    Dim tempValue As String
    Dim tempString As String

    tempArray = sRequest.Split(CChar("?"))
    If tempArray.Length <> 2 Then
        'url not valid
        Return
    End If
    tempValuePairs = tempArray(1).Split(CChar("&"))

    For Each tempString In tempValuePairs
        tempPair = tempString.Split(CChar("="))
        tempValue = tempPair(1)

        'check for pair name, tempvalue will contain data
        Select Case tempPair(0).ToLower
            Case "sender"
                mySender = tempValue
            Case "receiver"
            Case "msgdata"
            Case "recvtime"
            Case "msgid"
            Case Else
        End Select
    Next

Post a Comment for "How Can My Server Program Read The Variables Sent Using A HTTP 'GET' Request Method In VB.NET?"