can a forms action url contain querystring values?
Asked
Active
Viewed 3,142 times
2
-
1Change the method to `GET` instead of `POST` – Alex Sep 03 '10 at 22:07
-
Sample code about it for more explain question and more details for answer. – Kiquenet Jan 26 '17 at 14:10
3 Answers
2
Yes
it can.
But
when method="get"
then the querystring will be stripped out and replaced by the form input names/values (since the form controls are those that build the GET
querystring).
<form method="get" action="?param=foo">
<input type="hidden" name="param" value="bar" />
</form>
will submit param=bar
To keep the value you should specify method="post"
on the form
.
<form method="post" action="?param=foo">
<input type="hidden" name="otherparam" value="bar" />
</form>
will submit param=foo&otherparam=bar
<form method="post" action="?param=foo">
<input type="hidden" name="param" value="bar" />
</form>
will submit param=foo¶m=bar
(so, depending on how you process the request, you could get either an array value or unexpected results).

Kamafeather
- 8,663
- 14
- 69
- 99
1
Yes, it can.
(Keystrokes)

Matti Virkkunen
- 63,558
- 9
- 127
- 159
-
@Kiquenet: It's a "can you do X" question, it hardly needs any sample code. I'll rather vote to close this as a dupe of a better question that has more discussion about it. – Matti Virkkunen Jan 26 '17 at 12:59
0
I've just checked using a reduced test case:
- Form.htm that contains a form with an
action
ofdefault.aspx?query=1
and a submit button. - default.aspx that contains code in
Page_Load
to write outRequest.QueryString["query"]
The result I got when clicking on the button was a page that read:
1
So, the answer is yes.

Rob
- 45,296
- 24
- 122
- 150