473,386 Members | 1,795 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 2101
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Spud | last post by:
<?php // pullpage function by Nick bouton http://www.nickbouton.com/. $CustomerID = "IDHERE"; $method = "POST"; $host = "xml.mydata.com"; $usepath = "/xml.asp"; //print all vars in an...
7
by: Rui Pestana | last post by:
Hello all, I want to use the POST method to submit the form and then grab the parameters in the asp file with request.form("parm"). The problem is that I am using the _search target to open...
15
by: Thomas Scheiderich | last post by:
I am trying to understand Session variables and ran into a question on how they work with data that is passed. I have an HTM file that calls an ASP file and sends the name either by GET or POST....
2
by: Asp Help | last post by:
I'm working on a ASP applicatition to create Windows 2000 users. Because I don't want everybody to have access to the site I've changed te security in IIS 5.0 which runs on a windows 2000 Sp4...
2
by: Keith Selbee | last post by:
I am trying to submit data to a webpage in the form of a post and my code is below. It is a function that takes a url and the post content as strings and then performs the post. But as soon as I...
5
by: Tammy | last post by:
Hi, I have an aspx app which needs to post data to a form and read the response. I am confused on whether I should be using the get_url using "POST" method or the post_url using "GET" method. ...
7
by: | last post by:
Hello, I would like to do the following from a asp.net button click: <form method="POST" action="https://www.1234.com/trans_center/gateway/direct.cgi"> <input type="hidden" name="Merchant"...
24
by: moriman | last post by:
Hi, The script below *used* to work. I have only just set up a server, PHP etc again on my Win98 system and now it doesn't? On first loading this page, you would have $p = and the button...
56
by: UKuser | last post by:
Hi, I'm not sure if this can be done as I've searched the web and this forum. I am using an online merchant provider and I must post certain variables to their webforms through a form on my...
8
by: Kurda Yon | last post by:
Hi, I have to decide which form-method I should use (GET or POST). I found the following recomendation: If the service associated with the processing of a form has side effects (for example,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.