By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,191 Members | 2,190 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,191 IT Pros & Developers. It's quick & easy.

HTML POST

P: n/a
I have an HTML Form that uses GET and is processed by an ASP.NET 1.1 web
application.

Can you recommend a simple example of an HTML Form that uses POST and is
processed by an ASP.NET web application (either 1.1 or 2.0)?

What was the source of your information?

Thank you.

--
-- Thom Little -- www.tlanet.net -- Thom Little Associates, Ltd. .
--

Nov 24 '06 #1
Share this Question
Share on Google+
13 Replies


P: n/a
GET requires that the data be extracted from a querystring (because that how
GET causes the data to be transmitted).

i..e. x = Request.QueryString("txtUser")

POST allows you to simply ask for a specific piece of data by the name of
the control that contrained it before the data was posted.

i.e. x = txtUser.Text

"Thom Little" <th**@tlanet.netwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>I have an HTML Form that uses GET and is processed by an ASP.NET 1.1 web
application.

Can you recommend a simple example of an HTML Form that uses POST and is
processed by an ASP.NET web application (either 1.1 or 2.0)?

What was the source of your information?

Thank you.

--
-- Thom Little -- www.tlanet.net -- Thom Little Associates, Ltd. .
--

Nov 24 '06 #2

P: n/a
I was apparently confusing. I have been using GET and want to revise the
mechanism to use POST.

The form in question is an HTML form located on an .asp or .html (not .aspx)
page and invokes an .aspx page to process the form.

What I need is an example of trivial processing in the .aspx module that
accesses the data passed to it by the .asp or .html module.

--
-- Thom Little -- www.tlanet.net -- Thom Little Associates, Ltd.
--

"Scott M." <s-***@nospam.nospamwrote in message
news:ed**************@TK2MSFTNGP04.phx.gbl...
GET requires that the data be extracted from a querystring (because that
how GET causes the data to be transmitted).

i..e. x = Request.QueryString("txtUser")

POST allows you to simply ask for a specific piece of data by the name of
the control that contrained it before the data was posted.

i.e. x = txtUser.Text

Nov 24 '06 #3

P: n/a
Since you aren't on a 100% .NET platform, it really doesn't matter which you
sent it with (GET or POST), the Request object can retrieve either (just has
always been the case in classic asp).

Just use:

Request(theFormItemName)
"Thom Little" <th**@tlanet.netwrote in message
news:ur**************@TK2MSFTNGP03.phx.gbl...
>I was apparently confusing. I have been using GET and want to revise the
mechanism to use POST.

The form in question is an HTML form located on an .asp or .html (not
.aspx) page and invokes an .aspx page to process the form.

What I need is an example of trivial processing in the .aspx module that
accesses the data passed to it by the .asp or .html module.

--
-- Thom Little -- www.tlanet.net -- Thom Little Associates, Ltd.
--

"Scott M." <s-***@nospam.nospamwrote in message
news:ed**************@TK2MSFTNGP04.phx.gbl...
>GET requires that the data be extracted from a querystring (because that
how GET causes the data to be transmitted).

i..e. x = Request.QueryString("txtUser")

POST allows you to simply ask for a specific piece of data by the name of
the control that contrained it before the data was posted.

i.e. x = txtUser.Text


Nov 24 '06 #4

P: n/a
Thanks for the lead. Your cryptic reply assumes a lot more competence on my
part then actually exists. I really didn't know how it fit together.

With your hit and another lead from the wonderful Code Project I changed my
existing ...

NameValueCollection nvcQuery = Request.QueryString ;

... to ...

NameValueCollection nvcQuery ;
if ( Context.Request.Form.Count != 0 )
nvcQuery = Request.Form ;
else
nvcQuery = Request.QueryString ;

.... and this allows me to call the page using either GET or POST on the form
and process each paramater like ...

nvcQuery["firstname"]

Now I can convert my forms to POST and somewhat hide the values being
passed.

Thanks.

--
-- Thom Little -- www.tlanet.net -- Thom Little Associates, Ltd.
--

"Scott M." <s-***@nospam.nospamwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Since you aren't on a 100% .NET platform, it really doesn't matter which
you sent it with (GET or POST), the Request object can retrieve either
(just has always been the case in classic asp).

Just use:

Request(theFormItemName)
"Thom Little" <th**@tlanet.netwrote in message
news:ur**************@TK2MSFTNGP03.phx.gbl...
>>I was apparently confusing. I have been using GET and want to revise the
mechanism to use POST.

The form in question is an HTML form located on an .asp or .html (not
.aspx) page and invokes an .aspx page to process the form.

What I need is an example of trivial processing in the .aspx module that
accesses the data passed to it by the .asp or .html module.

--
-- Thom Little -- www.tlanet.net -- Thom Little Associates, Ltd.
--

"Scott M." <s-***@nospam.nospamwrote in message
news:ed**************@TK2MSFTNGP04.phx.gbl...
>>GET requires that the data be extracted from a querystring (because that
how GET causes the data to be transmitted).

i..e. x = Request.QueryString("txtUser")

POST allows you to simply ask for a specific piece of data by the name
of the control that contrained it before the data was posted.

i.e. x = txtUser.Text



Nov 24 '06 #5

P: n/a
You really don't need to go through all of that.

Request.Form(formItemName) will extract data out of the Forms collection
(used when form data is sent via POST)

Request.QueryString(formItemName) will extract data out of the QueryString
collection (used when form data is sent via GET)

Request(formItemName) will extract data from EITHER the Forms or QueryString
collection (regardless of where it is).

So, you don't need to check to see whether the data is in the Forms or
QueryString you can just write: nvcQuery["firstname"]


"Thom Little" <th**@tlanet.netwrote in message
news:Od**************@TK2MSFTNGP04.phx.gbl...
Thanks for the lead. Your cryptic reply assumes a lot more competence on
my part then actually exists. I really didn't know how it fit together.

With your hit and another lead from the wonderful Code Project I changed
my existing ...

NameValueCollection nvcQuery = Request.QueryString ;

... to ...

NameValueCollection nvcQuery ;
if ( Context.Request.Form.Count != 0 )
nvcQuery = Request.Form ;
else
nvcQuery = Request.QueryString ;

... and this allows me to call the page using either GET or POST on the
form and process each paramater like ...

nvcQuery["firstname"]

Now I can convert my forms to POST and somewhat hide the values being
passed.

Thanks.

--
-- Thom Little -- www.tlanet.net -- Thom Little Associates, Ltd.
--

"Scott M." <s-***@nospam.nospamwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>Since you aren't on a 100% .NET platform, it really doesn't matter which
you sent it with (GET or POST), the Request object can retrieve either
(just has always been the case in classic asp).

Just use:

Request(theFormItemName)
"Thom Little" <th**@tlanet.netwrote in message
news:ur**************@TK2MSFTNGP03.phx.gbl...
>>>I was apparently confusing. I have been using GET and want to revise the
mechanism to use POST.

The form in question is an HTML form located on an .asp or .html (not
.aspx) page and invokes an .aspx page to process the form.

What I need is an example of trivial processing in the .aspx module that
accesses the data passed to it by the .asp or .html module.

--
-- Thom Little -- www.tlanet.net -- Thom Little Associates, Ltd.
--

"Scott M." <s-***@nospam.nospamwrote in message
news:ed**************@TK2MSFTNGP04.phx.gbl...
GET requires that the data be extracted from a querystring (because
that how GET causes the data to be transmitted).

i..e. x = Request.QueryString("txtUser")

POST allows you to simply ask for a specific piece of data by the name
of the control that contrained it before the data was posted.

i.e. x = txtUser.Text




Nov 24 '06 #6

P: n/a
I think you meant to say that I could just write ...

Request("firstname") ... and not ... nvcQuery["firstname"]

My aspx program makes three passes through the data in the form to process
the data three different ways.

It is my understanding that Request("firstname") results in a server call
and each reference of this form would also result in a server call.

The approach I reported would be done in one server call.

I think the approach you recommend for a form with 50 fields would result in
150 server calls from my asmx page.

Was I misled?

--
-- Thom Little -- www.tlanet.net -- Thom Little Associates, Ltd.
--

"Scott M." <s-***@nospam.nospamwrote in message
news:uI**************@TK2MSFTNGP06.phx.gbl...
You really don't need to go through all of that.

Request.Form(formItemName) will extract data out of the Forms collection
(used when form data is sent via POST)

Request.QueryString(formItemName) will extract data out of the QueryString
collection (used when form data is sent via GET)

Request(formItemName) will extract data from EITHER the Forms or
QueryString collection (regardless of where it is).

So, you don't need to check to see whether the data is in the Forms or
QueryString you can just write: nvcQuery["firstname"]


"Thom Little" <th**@tlanet.netwrote in message
news:Od**************@TK2MSFTNGP04.phx.gbl...
>Thanks for the lead. Your cryptic reply assumes a lot more competence on
my part then actually exists. I really didn't know how it fit together.

With your hit and another lead from the wonderful Code Project I changed
my existing ...

NameValueCollection nvcQuery = Request.QueryString ;

... to ...

NameValueCollection nvcQuery ;
if ( Context.Request.Form.Count != 0 )
nvcQuery = Request.Form ;
else
nvcQuery = Request.QueryString ;

... and this allows me to call the page using either GET or POST on the
form and process each paramater like ...

nvcQuery["firstname"]

Now I can convert my forms to POST and somewhat hide the values being
passed.

Nov 24 '06 #7

P: n/a
ASPX code is server code. There are no server calls since all the code runs
on the server.

When a form sends its data (using either POST or GET), the data is sent to a
destination (in your case, an .aspx file residing on a server somewhere) and
processing control is handed over to that page. Once that page begins
processing, it doesn't need to make any "server calls" as you put it because
the data has already been sent to the server that is now processing the
code.

In other words, the server that is processing your .aspx code also already
contains the data sent to it from the .htm or .asp form, so there is no
additional overhead related to server calls with looking at the data once,
twice, or 500 times.

There are no performance implications here.
"Thom Little" <th**@tlanet.netwrote in message
news:%2***************@TK2MSFTNGP06.phx.gbl...
>I think you meant to say that I could just write ...

Request("firstname") ... and not ... nvcQuery["firstname"]

My aspx program makes three passes through the data in the form to process
the data three different ways.

It is my understanding that Request("firstname") results in a server call
and each reference of this form would also result in a server call.

The approach I reported would be done in one server call.

I think the approach you recommend for a form with 50 fields would result
in 150 server calls from my asmx page.

Was I misled?

--
-- Thom Little -- www.tlanet.net -- Thom Little Associates, Ltd.
--

"Scott M." <s-***@nospam.nospamwrote in message
news:uI**************@TK2MSFTNGP06.phx.gbl...
>You really don't need to go through all of that.

Request.Form(formItemName) will extract data out of the Forms collection
(used when form data is sent via POST)

Request.QueryString(formItemName) will extract data out of the
QueryString collection (used when form data is sent via GET)

Request(formItemName) will extract data from EITHER the Forms or
QueryString collection (regardless of where it is).

So, you don't need to check to see whether the data is in the Forms or
QueryString you can just write: nvcQuery["firstname"]


"Thom Little" <th**@tlanet.netwrote in message
news:Od**************@TK2MSFTNGP04.phx.gbl...
>>Thanks for the lead. Your cryptic reply assumes a lot more competence
on my part then actually exists. I really didn't know how it fit
together.

With your hit and another lead from the wonderful Code Project I changed
my existing ...

NameValueCollection nvcQuery = Request.QueryString ;

... to ...

NameValueCollection nvcQuery ;
if ( Context.Request.Form.Count != 0 )
nvcQuery = Request.Form ;
else
nvcQuery = Request.QueryString ;

... and this allows me to call the page using either GET or POST on the
form and process each paramater like ...

nvcQuery["firstname"]

Now I can convert my forms to POST and somewhat hide the values being
passed.


Nov 24 '06 #8

P: n/a
It is an excellent improvement. My code actually looks like ...

NameValueCollection nvcQuery = Request ;
String[] astrQuery = nvcQuery.AllKeys ;

.... the alternative ...

String[] astrQuery = Request.AllKeys ;

.... is invalid and if I instead try ...

String[] astrQuery = Request.Params.AllKeys ;

.... I get the form variables (GET or POST) plus the system parameters.

I need to limit it to the form variables.
Is there a better way to just get the form variables?

--
-- Thom Little -- www.tlanet.net -- Thom Little Associates, Ltd.
--

"Scott M." <s-***@nospam.nospamwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
ASPX code is server code. There are no server calls since all the code
runs on the server.

When a form sends its data (using either POST or GET), the data is sent to
a destination (in your case, an .aspx file residing on a server somewhere)
and processing control is handed over to that page. Once that page begins
processing, it doesn't need to make any "server calls" as you put it
because the data has already been sent to the server that is now
processing the code.

In other words, the server that is processing your .aspx code also already
contains the data sent to it from the .htm or .asp form, so there is no
additional overhead related to server calls with looking at the data once,
twice, or 500 times.

There are no performance implications here.

Nov 25 '06 #9

P: n/a
You could use a regular counting loop and just pass the Request object the
counter ( Request(counter) ). This would allow you to work with either
QueryString or Post data, but limits you to just obtaining the form values,
not the names of the form elements that sent the data.

If you want the names and values (which, I suspect you do), you need to use
the Form collection explicitly, as in:

VB.NET

dim item As Object
for each item in request.Form
response.write(item & "=" & request.Form(item))
next

"Thom Little" <th**@tlanet.netwrote in message
news:ua**************@TK2MSFTNGP04.phx.gbl...
It is an excellent improvement. My code actually looks like ...

NameValueCollection nvcQuery = Request ;
String[] astrQuery = nvcQuery.AllKeys ;

... the alternative ...

String[] astrQuery = Request.AllKeys ;

... is invalid and if I instead try ...

String[] astrQuery = Request.Params.AllKeys ;

... I get the form variables (GET or POST) plus the system parameters.

I need to limit it to the form variables.
Is there a better way to just get the form variables?

--
-- Thom Little -- www.tlanet.net -- Thom Little Associates, Ltd.
--

"Scott M." <s-***@nospam.nospamwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>ASPX code is server code. There are no server calls since all the code
runs on the server.

When a form sends its data (using either POST or GET), the data is sent
to a destination (in your case, an .aspx file residing on a server
somewhere) and processing control is handed over to that page. Once that
page begins processing, it doesn't need to make any "server calls" as you
put it because the data has already been sent to the server that is now
processing the code.

In other words, the server that is processing your .aspx code also
already contains the data sent to it from the .htm or .asp form, so there
is no additional overhead related to server calls with looking at the
data once, twice, or 500 times.

There are no performance implications here.


Nov 25 '06 #10

P: n/a
The counting approach is a good improvement but requires that I know if it
is GET or POST. If I do the following then it is properly limited for
either one.

NameValueCollection nvcRequest ;
if ( Context.Request.Form.Count != 0 )
nvcRequest = Request.Form ;
else
nvcRequest = Request.QueryString ;

foreach ( string strItem in nvcRequest )
{
}

--
-- Thom Little -- www.tlanet.net -- Thom Little Associates, Ltd.
--

"Scott M." <s-***@nospam.nospamwrote in message
news:uz****************@TK2MSFTNGP06.phx.gbl...
You could use a regular counting loop and just pass the Request object the
counter ( Request(counter) ). This would allow you to work with either
QueryString or Post data, but limits you to just obtaining the form
values, not the names of the form elements that sent the data.

If you want the names and values (which, I suspect you do), you need to
use the Form collection explicitly, as in:

VB.NET

dim item As Object
for each item in request.Form
response.write(item & "=" & request.Form(item))
next

Nov 25 '06 #11

P: n/a
Yes, but what is your point exactly? What are you dealing with and what are
your needs? If you tell us, we can give you the quickest solution.
"Thom Little" <th**@tlanet.netwrote in message
news:%2***************@TK2MSFTNGP03.phx.gbl...
The counting approach is a good improvement but requires that I know if it
is GET or POST. If I do the following then it is properly limited for
either one.

NameValueCollection nvcRequest ;
if ( Context.Request.Form.Count != 0 )
nvcRequest = Request.Form ;
else
nvcRequest = Request.QueryString ;

foreach ( string strItem in nvcRequest )
{
}

--
-- Thom Little -- www.tlanet.net -- Thom Little Associates, Ltd.
--

"Scott M." <s-***@nospam.nospamwrote in message
news:uz****************@TK2MSFTNGP06.phx.gbl...
>You could use a regular counting loop and just pass the Request object
the counter ( Request(counter) ). This would allow you to work with
either QueryString or Post data, but limits you to just obtaining the
form values, not the names of the form elements that sent the data.

If you want the names and values (which, I suspect you do), you need to
use the Form collection explicitly, as in:

VB.NET

dim item As Object
for each item in request.Form
response.write(item & "=" & request.Form(item))
next


Nov 25 '06 #12

P: n/a
Han
This is a very valuable thread for me.
I edited lots of my code after this.

"Thom Little" <th**@tlanet.netwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>I have an HTML Form that uses GET and is processed by an ASP.NET 1.1 web
application.

Can you recommend a simple example of an HTML Form that uses POST and is
processed by an ASP.NET web application (either 1.1 or 2.0)?

What was the source of your information?

Thank you.

--
-- Thom Little -- www.tlanet.net -- Thom Little Associates, Ltd. .
--

Nov 26 '06 #13

P: n/a
You did. You were very helpful. The optimal solution is now deployed.

The requirement was to have a single .ASPX page process either GET or POST
input.

The capability was a fairly large number of deployed .ASP and .HTML websites
that call a generalized form handling page written in ASP.NET 1.1. They all
use GET.

Because of e-mail address harvesting craze I have been removing all direct
e-mail references in my websites. I was also wanting to hide the parameters
from the query string.

If I had an .ASPX page that would process either GET or POST then I cold use
it immediately for all existing deployed websites (using GET) and use POST
in the future for new and revised websites.

This is where the requirement to process either or POST in the same .ASPX
page came from.

This page now exists and is enhanced by the suggestions that you made.

Thank you.

--
-- Thom Little -- www.tlanet.net -- Thom Little Associates, Ltd.
--

"Scott M." <s-***@nospam.nospamwrote in message
news:e6**************@TK2MSFTNGP06.phx.gbl...
Yes, but what is your point exactly? What are you dealing with and what
are your needs? If you tell us, we can give you the quickest solution.
"Thom Little" <th**@tlanet.netwrote in message
news:%2***************@TK2MSFTNGP03.phx.gbl...
>The counting approach is a good improvement but requires that I know if
it is GET or POST. If I do the following then it is properly limited for
either one.

NameValueCollection nvcRequest ;
if ( Context.Request.Form.Count != 0 )
nvcRequest = Request.Form ;
else
nvcRequest = Request.QueryString ;

foreach ( string strItem in nvcRequest )
{
}

--
-- Thom Little -- www.tlanet.net -- Thom Little Associates, Ltd.
--

"Scott M." <s-***@nospam.nospamwrote in message
news:uz****************@TK2MSFTNGP06.phx.gbl...
>>You could use a regular counting loop and just pass the Request object
the counter ( Request(counter) ). This would allow you to work with
either QueryString or Post data, but limits you to just obtaining the
form values, not the names of the form elements that sent the data.

If you want the names and values (which, I suspect you do), you need to
use the Form collection explicitly, as in:

VB.NET

dim item As Object
for each item in request.Form
response.write(item & "=" & request.Form(item))
next



Nov 26 '06 #14

This discussion thread is closed

Replies have been disabled for this discussion.