How to send POST to .net vb?

What I'm trying to do is get my user to enter a phone number and message, and then send it to the text marketing who will send the message.

for now, if I use response.redirect the meaning of the message.

response.redirect("http://www.textmarketer.biz/gateway/?username=*****&password=*****&message=test+message&orig=test&number=447712345678")

However, I do not want to send the user there. all I want to do is post the data in the url, and all this for now, and the user will remain on the current page.

Any help?

+5
source share
3 answers

in fact, you do not need to do this server side (vb), just html will do the trick:

<html>
    <body>
        <form action="http://google.com" method="post">
            <input type="hidden" value="somevalue"/>
            <input Type="submit" value="Submit"/>
        </form>
    </body>
</html>

this will publish the data (and essentially redirect) to google.com.

, script (jQuery) - $.ajax() $.post(). , ( , ).

HttpWebRequest. , , ( , ). request.GetResponse() . URL-, , .

:

VB:

Option Infer On
Imports System.Net
Imports System.Text


Public Class Test

    Private Sub TESTRUN()
        Dim s As HttpWebRequest
        Dim enc As UTF8Encoding
        Dim postdata As String
        Dim postdatabytes As Byte()
        s = HttpWebRequest.Create("http://www.textmarketer.biz/gateway/")
        enc = New System.Text.UTF8Encoding()
        postdata = "username=*****&password=*****&message=test+message&orig=test&number=447712345678"
        postdatabytes = enc.GetBytes(postdata)
        s.Method = "POST"
        s.ContentType = "application/x-www-form-urlencoded"
        s.ContentLength = postdatabytes.Length

        Using stream = s.GetRequestStream()
            stream.Write(postdatabytes, 0, postdatabytes.Length)
        End Using
        Dim result = s.GetResponse()
    End Sub
End Class

Update2:

GET HttpWebRequest VB.net.

Dim s As HttpWebRequest
Dim username = "username=" + HttpUtility.UrlEncode("yourusername")
Dim password = "password=" + HttpUtility.UrlEncode("yourp@assword)!==&@(*#)!@#(_")
Dim message = "message=" + HttpUtility.UrlEncode("yourmessage")
Dim orig = "orig=" + HttpUtility.UrlEncode("dunno what this is")
Dim num = "number=" + HttpUtility.UrlEncode("123456")
Dim sep = "&"
Dim sb As New StringBuilder()
sb.Append(username).Append(sep).Append(password).Append(sep)
sb.Append(message).Append(sep).Append(orig).Append(sep).Append(num)

s = HttpWebRequest.Create("http://www.textmarketer.biz/gateway/?" + sb.ToString())

s.Method = "GET"
Dim result = s.GetResponse()
+7
+2

you need to use the webrequest class. contact http://msdn.microsoft.com/en-us/library/debx8sh9.aspx

+2
source

All Articles