473,414 Members | 1,690 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,414 software developers and data experts.

HTML POST

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

Similar topics

0
by: Boris Ammerlaan | last post by:
This notice is posted about every week. I'll endeavor to use the same subject line so that those of you who have seen it can kill-file the subject; additionally, Supersedes: headers are used to...
19
Atli
by: Atli | last post by:
Introduction At some point, all web developers will need to collect data from their users. In a dynamic web page, everything revolves around the users input, so knowing how to ask for and collect...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.