468,746 Members | 1,878 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,746 developers. It's quick & easy.

POST method ?

WJ
I have an Asp.Net page that redirects the user to another page with a piece
of data to be passed. Below is the c# instruction:

Response.Redirect("mySpecialPage.aspx?go1="+strGoN ame);

This will expose the "go1" parameter on the Address field of the MS/IE
browser because it uses the "GET" method. Is there a way that I can force
the system to use the "POST" method with the above payload ?

Thanks for your help,

John
Nov 18 '05 #1
9 2010
POST a form to the URL. Response.Redirect() sends a header to the browser
instructing it to request that URL. That Request will always be GET. You
can't send a header to the browser instructing it to send a POST request.

You can add a non-WebForm (client-side) HTML form to the page anywhere
outside of the WebForm form. You can then use JavaScript to Post to its
ACTION property. A WebForm always has an ACTION property that is the same
URL as the page it's on. That's how ASP.Net does server-side event handling.
But you can certainly add another form to the page, set its ACTION property
to the URL you want to Post to, and submit it.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"WJ" <Jo*******@HotMail.Com> wrote in message
news:u6**************@TK2MSFTNGP12.phx.gbl...
I have an Asp.Net page that redirects the user to another page with a piece of data to be passed. Below is the c# instruction:

Response.Redirect("mySpecialPage.aspx?go1="+strGoN ame);

This will expose the "go1" parameter on the Address field of the MS/IE
browser because it uses the "GET" method. Is there a way that I can force
the system to use the "POST" method with the above payload ?

Thanks for your help,

John

Nov 18 '05 #2
WJ

"Kevin Spencer" <ks******@takempis.com> wrote in message
news:uq**************@TK2MSFTNGP12.phx.gbl...
POST a form to the URL. Response.Redirect() sends a header to the browser


Thanks for your response. I understand all this and I know that GET method
also uses form too. I just wonder why not make one for POST also. It is very
convenient.

John
Nov 18 '05 #3
> Thanks for your response. I understand all this and I know that GET method
also uses form too.
A Form can POST or GET, but Response.Redirect() is always GET. As for why,
you would have to ask the W3C.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"WJ" <Jo*******@HotMail.Com> wrote in message
news:e$**************@TK2MSFTNGP09.phx.gbl...
"Kevin Spencer" <ks******@takempis.com> wrote in message
news:uq**************@TK2MSFTNGP12.phx.gbl...
POST a form to the URL. Response.Redirect() sends a header to the
browser
Thanks for your response. I understand all this and I know that GET method
also uses form too. I just wonder why not make one for POST also. It is very convenient.

John

Nov 18 '05 #4
Hi John,

You can simulate a post using the WebClient class. Here's the idea:

Sub DoPost()
Dim uriString As String = _
"http://localhost/p4320work/mySpecialPage.aspx"
Dim strGoName As String
strGoName = TextBox1.Text
' Create a new WebClient instance.
Dim myWebClient As New System.Net.WebClient
Dim myNameValueCollection As New _
System.Collections.Specialized.NameValueCollection
myNameValueCollection.Add("go1", strGoName)
myNameValueCollection.Add("Button1", "")
Dim responseArray As Byte() = myWebClient.UploadValues _
(uriString, "POST", myNameValueCollection)

Label1.Text = "Response received was :" & _
System.Text.Encoding.ASCII.GetString(responseArray )
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Call DoPost()
End Sub

Ken
Microsoft MVP [ASP.NET]

"WJ" <Jo*******@HotMail.Com> wrote in message
news:u6**************@TK2MSFTNGP12.phx.gbl...
I have an Asp.Net page that redirects the user to another page with a piece
of data to be passed. Below is the c# instruction:

Response.Redirect("mySpecialPage.aspx?go1="+strGoN ame);

This will expose the "go1" parameter on the Address field of the MS/IE
browser because it uses the "GET" method. Is there a way that I can force
the system to use the "POST" method with the above payload ?

Thanks for your help,

John


Nov 18 '05 #5
WJ
Thanks Ken. That does it. However, it would be nice if the whole thing can
be condensed in one statement.

John
Nov 18 '05 #6
Glad to help.

I suppose I could spend some time on it. It might be a long statement!
<grin>

"WJ" <Jo*******@HotMail.Com> wrote in message
news:ep**************@TK2MSFTNGP09.phx.gbl...
Thanks Ken. That does it. However, it would be nice if the whole thing can
be condensed in one statement.

John


Nov 18 '05 #7
WJ
"Ken Cox [Microsoft MVP]" <BA************@sympatico.ca> wrote in message
news:ei**************@tk2msftngp13.phx.gbl...
I suppose I could spend some time on it. It might be a long statement!
<grin>


You done enough already. Let Bill Gate does it. All I need is a
Response.Redirect("mySpecialPage.aspx?go1="+strGoN ame,"POST");

:)

John

Nov 18 '05 #8
You might want to submit it as a product suggestion. There's a big push on
to get developer feedback:

http://lab.msdn.microsoft.com/productfeedback/

You done enough already. Let Bill Gate does it. All I need is a
Response.Redirect("mySpecialPage.aspx?go1="+strGoN ame,"POST");


Nov 18 '05 #9
Dear Ken,
if i have an asp page with 2 input controls (username & password),i want
from my asp.net page to post these data and submit the form and see the
returned URL,if the user has been authenticated or not.

all sample i have seen is to pass the data on POST ,considering the page is
working by passing values as Quesry string.... if not ? this method is work
using HTTPWeb Request...... or there's another method to do the above
scenario.

i want a sample code to this.
what i did,simpy i went to the login page of that system,and take the
Control IDs for the username and password.....but pass it as content on POST
doesnt work.....

please clarify my ideas if there's sometinhg wrong.

"Ken Cox [Microsoft MVP]" wrote:
Hi John,

You can simulate a post using the WebClient class. Here's the idea:

Sub DoPost()
Dim uriString As String = _
"http://localhost/p4320work/mySpecialPage.aspx"
Dim strGoName As String
strGoName = TextBox1.Text
' Create a new WebClient instance.
Dim myWebClient As New System.Net.WebClient
Dim myNameValueCollection As New _
System.Collections.Specialized.NameValueCollection
myNameValueCollection.Add("go1", strGoName)
myNameValueCollection.Add("Button1", "")
Dim responseArray As Byte() = myWebClient.UploadValues _
(uriString, "POST", myNameValueCollection)

Label1.Text = "Response received was :" & _
System.Text.Encoding.ASCII.GetString(responseArray )
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Call DoPost()
End Sub

Ken
Microsoft MVP [ASP.NET]

"WJ" <Jo*******@HotMail.Comwrote in message
news:u6**************@TK2MSFTNGP12.phx.gbl...
I have an Asp.Net page that redirects the user to another page with a piece
of data to be passed. Below is the c# instruction:

Response.Redirect("mySpecialPage.aspx?go1="+strGoN ame);

This will expose the "go1" parameter on the Address field of the MS/IE
browser because it uses the "GET" method. Is there a way that I can force
the system to use the "POST" method with the above payload ?

Thanks for your help,

John

Oct 5 '06 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

15 posts views Thread by Thomas Scheiderich | last post: by
2 posts views Thread by Keith Selbee | last post: by
24 posts views Thread by moriman | last post: by
56 posts views Thread by UKuser | last post: by
8 posts views Thread by Kurda Yon | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
xarzu
2 posts views Thread by xarzu | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.