How to set RequestType to POST?

  • Thread starter Martin Feuersteiner
  • Start date
M

Martin Feuersteiner

Dear Group

I'm having trouble with the script below. How do I set the RequestType so
the script will use POST instead of GET?
I tried the script below with no luck.

Thanks for your time & efforts!

Martin

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Request.RequestType = "POST"

'Open Database Connection
clsData.OpenSQLConnection()

Dim prm1 As SqlClient.SqlParameter 'SenderTxt
Dim prm2 As SqlClient.SqlParameter 'TimeTxt
Dim prm3 As SqlClient.SqlParameter 'MessageTxt
Dim prm4 As SqlClient.SqlParameter 'KeywordTxt

Dim str1 As String = "EXEC sp_SaveSMS @SenderTxt, @TimeTxt,
@MessageTxt, @KeywordTxt"
Dim cmd1 As New SqlClient.SqlCommand(str1, SQLConnection)

prm1 = cmd1.CreateParameter
With prm1
.ParameterName = "@SenderTxt"
.SqlDbType = SqlDbType.VarChar
.Value = CStr(Request.QueryString("sender"))
End With

prm2 = cmd1.CreateParameter
With prm2
.ParameterName = "@TimeTxt"
.SqlDbType = SqlDbType.VarChar
.Value = CStr(Request.QueryString("time"))
End With

prm3 = cmd1.CreateParameter
With prm3
.ParameterName = "@MessageTxt"
.SqlDbType = SqlDbType.VarChar
.Value = CStr(Request.QueryString("message"))
End With

prm4 = cmd1.CreateParameter
With prm4
.ParameterName = "@KeywordTxt"
.SqlDbType = SqlDbType.VarChar
.Value = CStr(Request.QueryString("keyword"))
End With

cmd1.Parameters.Add(prm1)
cmd1.Parameters.Add(prm2)
cmd1.Parameters.Add(prm3)
cmd1.Parameters.Add(prm4)

Try
cmd1.ExecuteNonQuery()

Finally
clsData.CloseSQLConnection()
End Try

End Sub
 
R

Rick Spiewak

You can't change the type of the current request, that doesn't make any
sense. What are you trying to accomplish?
 
M

Martin Feuersteiner

Hi Rick
Thanks for helping!

I need to process data sent to me by a 3rd party, in this case a sms
gateway.

When I test the page by typing this URLQuerystring in my browser address
bar,
http://www.mydomain.com/app/smsinbox.aspx?sender=Me&time=Now&message=Hello&keyword=i2b,
everything works perfectly fine.

But when the sms gateway sends me data using exactly the same format, it
doesn't get processed.

I was told that I need to use POST instead of GET for my script. When I look
at my IIS raw log files, data sent via the browser address bar uses GET and
the sms gateway uses POST. I can't change what method the SMS gateway uses
just was told to adapt my script to use POST.

Thanks very much for your time and efforts!

Martin
 
G

George Ter-Saakov

Not sure what is your problem but sounds like you should be using
Request.Form["variablename"] instead of Request.QueryString["variablename"]
to access those parameters.

George.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top