Connecting Tech Pros Worldwide Help | Site Map

Session variables and POST method

Thomas Scheiderich
Guest
 
Posts: n/a
#1: Jul 19 '05
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.

When I find is that if I send the value by the GET method,
response.write("From QueryString: " &
Request.QueryString("usernamefromform") & "<br><br>")

will get the variable fine, but

Session("userName")=request.Form("userNameFromForm ")
response.write("Session variable = " & Session("userName"))

doesn't work.

If I use the POST method then it is reversed. Response.QueryString
doesn't get anything and the Session code works.

Why is this? I can't seem to find an explanation in my ASP books.

Thanks,

Tom

Ray at
Guest
 
Posts: n/a
#2: Jul 19 '05

re: Session variables and POST method


When using method=post, request.Form will not have anything in it. To debug
such a thing or see such a thing, use response.write to see what's going on,
as a general practice.

sTest = Request.form("usernamefromform")
Response.WRite "The value of sTest is " & sTest

Ray at work

"Thomas Scheiderich" <tfs@deltanet.com> wrote in message
news:4023F533.5050400@deltanet.com...[color=blue]
> 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.
>
> When I find is that if I send the value by the GET method,
> response.write("From QueryString: " &
> Request.QueryString("usernamefromform") & "<br><br>")
>
> will get the variable fine, but
>
> Session("userName")=request.Form("userNameFromForm ")
> response.write("Session variable = " & Session("userName"))
>
> doesn't work.
>
> If I use the POST method then it is reversed. Response.QueryString
> doesn't get anything and the Session code works.
>
> Why is this? I can't seem to find an explanation in my ASP books.
>
> Thanks,
>
> Tom
>[/color]


Ray at
Guest
 
Posts: n/a
#3: Jul 19 '05

re: Session variables and POST method


I meant method=get!

Ray at work

"Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in
message news:%23HeSX5O7DHA.2088@TK2MSFTNGP10.phx.gbl...[color=blue]
> When using method=post, request.Form will not have anything in it. To[/color]
debug[color=blue]
> such a thing or see such a thing, use response.write to see what's going[/color]
on,[color=blue]
> as a general practice.
>
> sTest = Request.form("usernamefromform")
> Response.WRite "The value of sTest is " & sTest
>
> Ray at work
>
> "Thomas Scheiderich" <tfs@deltanet.com> wrote in message
> news:4023F533.5050400@deltanet.com...[color=green]
> > 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.
> >
> > When I find is that if I send the value by the GET method,
> > response.write("From QueryString: " &
> > Request.QueryString("usernamefromform") & "<br><br>")
> >
> > will get the variable fine, but
> >
> > Session("userName")=request.Form("userNameFromForm ")
> > response.write("Session variable = " & Session("userName"))
> >
> > doesn't work.
> >
> > If I use the POST method then it is reversed. Response.QueryString
> > doesn't get anything and the Session code works.
> >
> > Why is this? I can't seem to find an explanation in my ASP books.
> >
> > Thanks,
> >
> > Tom
> >[/color]
>
>[/color]


Peter Foti
Guest
 
Posts: n/a
#4: Jul 19 '05

re: Session variables and POST method


"Thomas Scheiderich" <tfs@deltanet.com> wrote in message
news:4023F533.5050400@deltanet.com...[color=blue]
> 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.
>
> When I find is that if I send the value by the GET method,
> response.write("From QueryString: " &
> Request.QueryString("usernamefromform") & "<br><br>")
>
> will get the variable fine, but
>
> Session("userName")=request.Form("userNameFromForm ")
> response.write("Session variable = " & Session("userName"))
>
> doesn't work.
>
> If I use the POST method then it is reversed. Response.QueryString
> doesn't get anything and the Session code works.
>
> Why is this? I can't seem to find an explanation in my ASP books.[/color]

When using method GET, you can access the form values via the
Request.Querystring collection. When using method POST, you can access the
form values via the Request.Form collection.

Regards,
Peter Foti


Thomas Scheiderich
Guest
 
Posts: n/a
#5: Jul 19 '05

re: Session variables and POST method


Peter Foti wrote:
[color=blue]
> "Thomas Scheiderich" <tfs@deltanet.com> wrote in message
> news:4023F533.5050400@deltanet.com...
>[color=green]
>>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.
>>
>>When I find is that if I send the value by the GET method,
>> response.write("From QueryString: " &
>>Request.QueryString("usernamefromform") & "<br><br>")
>>
>> will get the variable fine, but
>>
>>Session("userName")=request.Form("userNameFromFo rm")
>>response.write("Session variable = " & Session("userName"))
>>
>>doesn't work.
>>
>>If I use the POST method then it is reversed. Response.QueryString
>>doesn't get anything and the Session code works.
>>
>>Why is this? I can't seem to find an explanation in my ASP books.
>>[/color]
>
> When using method GET, you can access the form values via the
> Request.Querystring collection. When using method POST, you can access the
> form values via the Request.Form collection.
>[/color]

Why is that?

Aren't they both forms? I would have thought that the Request.Form,
would still be able to get the data.

I know that the difference between GET and POST is that you can see the
data that is passed in the URL line in your browser, but you can't in
the POST method.

Tom.

[color=blue]
> Regards,
> Peter Foti
>
>
>[/color]

Bob Barrows
Guest
 
Posts: n/a
#6: Jul 19 '05

re: Session variables and POST method


Thomas Scheiderich wrote:[color=blue]
> Peter Foti wrote:
>[color=green]
>> "Thomas Scheiderich" <tfs@deltanet.com> wrote in message
>> news:4023F533.5050400@deltanet.com...
>>[color=darkred]
>>> 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.
>>>
>>> When I find is that if I send the value by the GET method,
>>> response.write("From QueryString: " &
>>> Request.QueryString("usernamefromform") & "<br><br>")
>>>
>>> will get the variable fine, but
>>>
>>> Session("userName")=request.Form("userNameFromForm ")
>>> response.write("Session variable = " & Session("userName"))
>>>
>>> doesn't work.
>>>
>>> If I use the POST method then it is reversed. Response.QueryString
>>> doesn't get anything and the Session code works.
>>>
>>> Why is this? I can't seem to find an explanation in my ASP books.
>>>[/color]
>>
>> When using method GET, you can access the form values via the
>> Request.Querystring collection. When using method POST, you can
>> access the form values via the Request.Form collection.
>>[/color]
>
> Why is that?
>
> Aren't they both forms? I would have thought that the Request.Form,
> would still be able to get the data.
>
> I know that the difference between GET and POST is that you can see
> the
> data that is passed in the URL line in your browser, but you can't in
> the POST method.
>
> Tom.
>
>[color=green]
>> Regards,
>> Peter Foti[/color][/color]

I have never had any problem getting both querystring and form variable
values when using post.

<form action="somepage.asp?qstr=somevalue" method=post>

As you can see, when using post, you have to add the querystring values
yourself, but they do get passed along with the form values.

Bob Barrows


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


Bob Barrows
Guest
 
Posts: n/a
#7: Jul 19 '05

re: Session variables and POST method


Thomas Scheiderich wrote:[color=blue]
> 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.
>
> When I find is that if I send the value by the GET method,
> response.write("From QueryString: " &
> Request.QueryString("usernamefromform") & "<br><br>")
>
> will get the variable fine, but
>
> Session("userName")=request.Form("userNameFromForm ")
> response.write("Session variable = " & Session("userName"))
>
> doesn't work.
>[/color]
What does "doesn't work" mean? We're not looking over your shoulder as you
do these tests ... :-)

Have you verified that request.Form("userNameFromForm") contains a value?
(I'm assuming you changed your submit method to POST when you tried this
....)

Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


Thomas Scheiderich
Guest
 
Posts: n/a
#8: Jul 19 '05

re: Session variables and POST method


Bob Barrows wrote:
[color=blue]
> Thomas Scheiderich wrote:
>[color=green]
>>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.
>>
>>When I find is that if I send the value by the GET method,
>> response.write("From QueryString: " &
>>Request.QueryString("usernamefromform") & "<br><br>")
>>
>> will get the variable fine, but
>>
>>Session("userName")=request.Form("userNameFromFo rm")
>>response.write("Session variable = " & Session("userName"))
>>
>>doesn't work.
>>
>>[/color]
> What does "doesn't work" mean? We're not looking over your shoulder as you
> do these tests ... :-)
>[/color]


The page that calls this has this code in it:

<Form action="sessionvar.asp" method="POST">
<input type="text" name="userNameFromForm">
<input type="submit" value="Send It">

When it is like this, the "Session" code works (meaning the second line
will show the userName), but the QueryString will not.

If I change it to GET, the the QueryString will display the name and the
Session code will not.

[color=blue]
> Have you verified that request.Form("userNameFromForm") contains a value?
> (I'm assuming you changed your submit method to POST when you tried this
> ...)[/color]


Yes, I do and it does. As I say, it either works in one or the other
depending on method.

Thanks,

Tom.

[color=blue]
>
> Bob Barrows
>[/color]

Ray at
Guest
 
Posts: n/a
#9: Jul 19 '05

re: Session variables and POST method





"Thomas Scheiderich" <tfs@deltanet.com> wrote in message
news:4025AC20.9080604@deltanet.com...[color=blue]
>
> When it is like this, the "Session" code works (meaning the second line
> will show the userName), but the QueryString will not.[/color]

Your problem isn't session related. It has to do with understanding that
METHOD=GET transfers the form data to the server by means of the querystring
: USER REQUEST.QUERYSTRING.

METHOD=POST transfers the form data to the server by means of post data. :
USE REQUEST.FORM


Method Used | Collection Populated
------------|---------------------
METHOD=POST | Request.Form
METHOD=GET | Request.Querystring


Ray at home


Thomas Scheiderich
Guest
 
Posts: n/a
#10: Jul 19 '05

re: Session variables and POST method


Ray at <%=sLocation%> [MVP] wrote:
[color=blue]
> "Thomas Scheiderich" <tfs@deltanet.com> wrote in message
> news:4025AC20.9080604@deltanet.com...
>[color=green]
>>When it is like this, the "Session" code works (meaning the second line
>>will show the userName), but the QueryString will not.
>>[/color]
>
> Your problem isn't session related. It has to do with understanding that
> METHOD=GET transfers the form data to the server by means of the querystring
> : USER REQUEST.QUERYSTRING.
>
> METHOD=POST transfers the form data to the server by means of post data. :
> USE REQUEST.FORM[/color]


What is Post Data and why is it different from the querystring?

Tom.

[color=blue]
>
>
> Method Used | Collection Populated
> ------------|---------------------
> METHOD=POST | Request.Form
> METHOD=GET | Request.Querystring
>
>
> Ray at home
>
>
>[/color]

Ray at
Guest
 
Posts: n/a
#11: Jul 19 '05

re: Session variables and POST method


I suggest you buy an ASP book. My favorite beginner's book is Beginning
Active Server Pages 3.0 from Wrox.
http://www.amazon.com/exec/obidos/AS...023492-2159024

Post requests append the form data onto the end of the http request. Get
sticks the data in the url request. Here's a little more info.
http://www.cs.tut.fi/~jkorpela/forms/methods.html

--

Ray at home
Microsoft ASP MVP


"Thomas Scheiderich" <tfs@deltanet.com> wrote in message
news:4025C533.5090305@deltanet.com...[color=blue]
> Ray at <%=sLocation%> [MVP] wrote:
>[color=green]
> > "Thomas Scheiderich" <tfs@deltanet.com> wrote in message
> > news:4025AC20.9080604@deltanet.com...
> >[color=darkred]
> >>When it is like this, the "Session" code works (meaning the second line
> >>will show the userName), but the QueryString will not.
> >>[/color]
> >
> > Your problem isn't session related. It has to do with understanding[/color][/color]
that[color=blue][color=green]
> > METHOD=GET transfers the form data to the server by means of the[/color][/color]
querystring[color=blue][color=green]
> > : USER REQUEST.QUERYSTRING.
> >
> > METHOD=POST transfers the form data to the server by means of post data.[/color][/color]
:[color=blue][color=green]
> > USE REQUEST.FORM[/color]
>
>
> What is Post Data and why is it different from the querystring?
>
> Tom.
>
>[color=green]
> >
> >
> > Method Used | Collection Populated
> > ------------|---------------------
> > METHOD=POST | Request.Form
> > METHOD=GET | Request.Querystring
> >
> >
> > Ray at home
> >
> >
> >[/color]
>[/color]


Peter Foti
Guest
 
Posts: n/a
#12: Jul 19 '05

re: Session variables and POST method


"Thomas Scheiderich" <tfs@deltanet.com> wrote in message
news:402515A8.1080707@deltanet.com...[color=blue]
> Peter Foti wrote:
>[color=green]
> > "Thomas Scheiderich" <tfs@deltanet.com> wrote in message
> > news:4023F533.5050400@deltanet.com...
> >[color=darkred]
> >>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.
> >>
> >>When I find is that if I send the value by the GET method,
> >> response.write("From QueryString: " &
> >>Request.QueryString("usernamefromform") & "<br><br>")
> >>
> >> will get the variable fine, but
> >>
> >>Session("userName")=request.Form("userNameFromFo rm")
> >>response.write("Session variable = " & Session("userName"))
> >>
> >>doesn't work.
> >>
> >>If I use the POST method then it is reversed. Response.QueryString
> >>doesn't get anything and the Session code works.
> >>
> >>Why is this? I can't seem to find an explanation in my ASP books.
> >>[/color]
> >
> > When using method GET, you can access the form values via the
> > Request.Querystring collection. When using method POST, you can access[/color][/color]
the[color=blue][color=green]
> > form values via the Request.Form collection.
> >[/color]
>
> Why is that?
>
> Aren't they both forms? I would have thought that the Request.Form,
> would still be able to get the data.
>
> I know that the difference between GET and POST is that you can see the
> data that is passed in the URL line in your browser, but you can't in
> the POST method.[/color]

The method actually specifies which HTTP method is used to send the form to
the processing agent. With the HTTP "get" method, the form data is appended
to the URI specified by the action attribute, and this new URI is sent to
the processing agent. With the HTTP "post" method, the form data is
included in the body of the form and sent to the processing agent. Thus,
with the "get" method, your form data is transferred to the querystring, and
with the "post" method, it remains in the form.

Hope that helps. For more info, you might try looking up HTTP and/or HTML
Forms (www.w3.org is a good starting point).
Regards,
Peter Foti


Thomas Scheiderich
Guest
 
Posts: n/a
#13: Jul 19 '05

re: Session variables and POST method


Peter Foti wrote:
[color=blue]
> "Thomas Scheiderich" <tfs@deltanet.com> wrote in message
> news:402515A8.1080707@deltanet.com...
>[color=green]
>>Peter Foti wrote:
>>
>>[color=darkred]
>>>"Thomas Scheiderich" <tfs@deltanet.com> wrote in message
>>>news:4023F533.5050400@deltanet.com...
>>>
>>>
>>>>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.
>>>>
>>>>When I find is that if I send the value by the GET method,
>>>> response.write("From QueryString: " &
>>>>Request.QueryString("usernamefromform") & "<br><br>")
>>>>
>>>> will get the variable fine, but
>>>>
>>>>Session("userName")=request.Form("userNameFrom Form")
>>>>response.write("Session variable = " & Session("userName"))
>>>>
>>>>doesn't work.
>>>>
>>>>If I use the POST method then it is reversed. Response.QueryString
>>>>doesn't get anything and the Session code works.
>>>>
>>>>Why is this? I can't seem to find an explanation in my ASP books.
>>>>
>>>>
>>>When using method GET, you can access the form values via the
>>>Request.Querystring collection. When using method POST, you can access
>>>[/color][/color]
> the
>[color=green][color=darkred]
>>>form values via the Request.Form collection.
>>>
>>>[/color]
>>Why is that?
>>
>>Aren't they both forms? I would have thought that the Request.Form,
>>would still be able to get the data.
>>
>>I know that the difference between GET and POST is that you can see the
>>data that is passed in the URL line in your browser, but you can't in
>>the POST method.
>>[/color]
>
> The method actually specifies which HTTP method is used to send the form to
> the processing agent. With the HTTP "get" method, the form data is appended
> to the URI specified by the action attribute, and this new URI is sent to
> the processing agent. With the HTTP "post" method, the form data is
> included in the body of the form and sent to the processing agent. Thus,
> with the "get" method, your form data is transferred to the querystring, and
> with the "post" method, it remains in the form.[/color]


This is a "just curious" question as I understand now what "post" does,
but everyone says that the "post" method is appended to the form data
and then passed to the processing agent.

In the "get" method, the URL/URI with the query string appended after
the "?" is sent to the processor. What is actually sent to the
processor for "POST"? When you say the body of the form with the form
data, are you talking about an HTML page that just has the form
information (no graphics,tables etc.).


I assume the data somehow gets sent to the client for the browser to
handle. Where does the data get put for the client to handle for things
such as putting into cookies as well as putting on the screen?

Thanks,

Tom.

[color=blue]
>
> Hope that helps. For more info, you might try looking up HTTP and/or HTML
> Forms (www.w3.org is a good starting point).
> Regards,
> Peter Foti
>
>
>[/color]

Peter Foti
Guest
 
Posts: n/a
#14: Jul 19 '05

re: Session variables and POST method


"Thomas Scheiderich" <tfs@deltanet.com> wrote in message
news:4027CEB5.2010403@deltanet.com...[color=blue]
> Peter Foti wrote:
>[color=green]
> > "Thomas Scheiderich" <tfs@deltanet.com> wrote in message
> > news:402515A8.1080707@deltanet.com...
> >[color=darkred]
> >>Peter Foti wrote:
> >>
> >>
> >>>"Thomas Scheiderich" <tfs@deltanet.com> wrote in message
> >>>news:4023F533.5050400@deltanet.com...
> >>>
> >>>
> >>>>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.
> >>>>
> >>>>When I find is that if I send the value by the GET method,
> >>>> response.write("From QueryString: " &
> >>>>Request.QueryString("usernamefromform") & "<br><br>")
> >>>>
> >>>> will get the variable fine, but
> >>>>
> >>>>Session("userName")=request.Form("userNameFrom Form")
> >>>>response.write("Session variable = " & Session("userName"))
> >>>>
> >>>>doesn't work.
> >>>>
> >>>>If I use the POST method then it is reversed. Response.QueryString
> >>>>doesn't get anything and the Session code works.
> >>>>
> >>>>Why is this? I can't seem to find an explanation in my ASP books.
> >>>>
> >>>>
> >>>When using method GET, you can access the form values via the
> >>>Request.Querystring collection. When using method POST, you can access
> >>>[/color]
> > the
> >[color=darkred]
> >>>form values via the Request.Form collection.
> >>>
> >>>
> >>Why is that?
> >>
> >>Aren't they both forms? I would have thought that the Request.Form,
> >>would still be able to get the data.
> >>
> >>I know that the difference between GET and POST is that you can see the
> >>data that is passed in the URL line in your browser, but you can't in
> >>the POST method.
> >>[/color]
> >
> > The method actually specifies which HTTP method is used to send the form[/color][/color]
to[color=blue][color=green]
> > the processing agent. With the HTTP "get" method, the form data is[/color][/color]
appended[color=blue][color=green]
> > to the URI specified by the action attribute, and this new URI is sent[/color][/color]
to[color=blue][color=green]
> > the processing agent. With the HTTP "post" method, the form data is
> > included in the body of the form and sent to the processing agent.[/color][/color]
Thus,[color=blue][color=green]
> > with the "get" method, your form data is transferred to the querystring,[/color][/color]
and[color=blue][color=green]
> > with the "post" method, it remains in the form.[/color]
>
>
> This is a "just curious" question as I understand now what "post" does,
> but everyone says that the "post" method is appended to the form data
> and then passed to the processing agent.
>
> In the "get" method, the URL/URI with the query string appended after
> the "?" is sent to the processor. What is actually sent to the
> processor for "POST"? When you say the body of the form with the form
> data, are you talking about an HTML page that just has the form
> information (no graphics,tables etc.).[/color]

When a form is submitted for processing, some controls have their name
paired with their current value and these pairs are submitted with the form.
Those controls for which name/value pairs are submitted are called
successful controls.

Read this section of the spec for more details regarding how form data is
processed:
http://www.w3.org/TR/html4/interact/...html#h-17.13.3

In addition, you might read the relavent portions of the HTTP spec (section
9.5 for example):
http://www.ietf.org/rfc/rfc2616.txt

[color=blue]
> I assume the data somehow gets sent to the client for the browser to
> handle. Where does the data get put for the client to handle for things
> such as putting into cookies as well as putting on the screen?[/color]

Why would you assume such a thing??? Form processing occurs on the server,
not on the client or browser. The server can tell the client that there is
a cookie, and that is handled by each browser individually (as far as where
is stores the cookie).

The spec should answer most of your questions.
Regards,
Peter Foti


Mark Schupp
Guest
 
Posts: n/a
#15: Jul 19 '05

re: Session variables and POST method


Here is what POST and GET requests actually send:


***********post****************
POST /test.asp HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint,
application/x-shockwave-flash, */*
Referer: http://localhost/test.html
Accept-Language: en-us
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)
Host: localhost
Content-Length: 59
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: ASPSESSIONIDCABBTSDS=HDMDFOODHJFOJHCCKJIIDOIF

field1=field+1+data&field2=field+2+data&field3=fie ld+3+data




***************get*******************************
GET /test.asp?field1=field+1+data&field2=field+2+data&f ield3=field+3+data
HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint,
application/x-shockwave-flash, */*
Referer: http://localhost/test.html
Accept-Language: en-us
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)
Host: localhost
Connection: Keep-Alive
Cookie: ASPSESSIONIDCABBTSDS=HDMDFOODHJFOJHCCKJIIDOIF


--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com


"Thomas Scheiderich" <tfs@deltanet.com> wrote in message
news:4027CEB5.2010403@deltanet.com...[color=blue]
> Peter Foti wrote:
>[color=green]
> > "Thomas Scheiderich" <tfs@deltanet.com> wrote in message
> > news:402515A8.1080707@deltanet.com...
> >[color=darkred]
> >>Peter Foti wrote:
> >>
> >>
> >>>"Thomas Scheiderich" <tfs@deltanet.com> wrote in message
> >>>news:4023F533.5050400@deltanet.com...
> >>>
> >>>
> >>>>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.
> >>>>
> >>>>When I find is that if I send the value by the GET method,
> >>>> response.write("From QueryString: " &
> >>>>Request.QueryString("usernamefromform") & "<br><br>")
> >>>>
> >>>> will get the variable fine, but
> >>>>
> >>>>Session("userName")=request.Form("userNameFrom Form")
> >>>>response.write("Session variable = " & Session("userName"))
> >>>>
> >>>>doesn't work.
> >>>>
> >>>>If I use the POST method then it is reversed. Response.QueryString
> >>>>doesn't get anything and the Session code works.
> >>>>
> >>>>Why is this? I can't seem to find an explanation in my ASP books.
> >>>>
> >>>>
> >>>When using method GET, you can access the form values via the
> >>>Request.Querystring collection. When using method POST, you can access
> >>>[/color]
> > the
> >[color=darkred]
> >>>form values via the Request.Form collection.
> >>>
> >>>
> >>Why is that?
> >>
> >>Aren't they both forms? I would have thought that the Request.Form,
> >>would still be able to get the data.
> >>
> >>I know that the difference between GET and POST is that you can see the
> >>data that is passed in the URL line in your browser, but you can't in
> >>the POST method.
> >>[/color]
> >
> > The method actually specifies which HTTP method is used to send the form[/color][/color]
to[color=blue][color=green]
> > the processing agent. With the HTTP "get" method, the form data is[/color][/color]
appended[color=blue][color=green]
> > to the URI specified by the action attribute, and this new URI is sent[/color][/color]
to[color=blue][color=green]
> > the processing agent. With the HTTP "post" method, the form data is
> > included in the body of the form and sent to the processing agent.[/color][/color]
Thus,[color=blue][color=green]
> > with the "get" method, your form data is transferred to the querystring,[/color][/color]
and[color=blue][color=green]
> > with the "post" method, it remains in the form.[/color]
>
>
> This is a "just curious" question as I understand now what "post" does,
> but everyone says that the "post" method is appended to the form data
> and then passed to the processing agent.
>
> In the "get" method, the URL/URI with the query string appended after
> the "?" is sent to the processor. What is actually sent to the
> processor for "POST"? When you say the body of the form with the form
> data, are you talking about an HTML page that just has the form
> information (no graphics,tables etc.).
>
>
> I assume the data somehow gets sent to the client for the browser to
> handle. Where does the data get put for the client to handle for things
> such as putting into cookies as well as putting on the screen?
>
> Thanks,
>
> Tom.
>
>[color=green]
> >
> > Hope that helps. For more info, you might try looking up HTTP and/or[/color][/color]
HTML[color=blue][color=green]
> > Forms (www.w3.org is a good starting point).
> > Regards,
> > Peter Foti
> >
> >
> >[/color]
>[/color]


Thomas Scheiderich
Guest
 
Posts: n/a
#16: Jul 19 '05

re: Session variables and POST method


Peter Foti wrote:
[color=blue]
> "Thomas Scheiderich" <tfs@deltanet.com> wrote in message
> news:4027CEB5.2010403@deltanet.com...
>[color=green]
>>Peter Foti wrote:
>>
>>[color=darkred]
>>>"Thomas Scheiderich" <tfs@deltanet.com> wrote in message
>>>news:402515A8.1080707@deltanet.com...
>>>
>>>
>>>>Peter Foti wrote:
>>>>
>>>>
>>>>
>>>>>"Thomas Scheiderich" <tfs@deltanet.com> wrote in message
>>>>>news:4023F533.5050400@deltanet.com...
>>>>>
>>>>>
>>>>>
>>>>>>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.
>>>>>>
>>>>>>When I find is that if I send the value by the GET method,
>>>>>>response.write("From QueryString: " &
>>>>>>Request.QueryString("usernamefromform") & "<br><br>")
>>>>>>
>>>>>>will get the variable fine, but
>>>>>>
>>>>>>Session("userName")=request.Form("userNameFr omForm")
>>>>>>response.write("Session variable = " & Session("userName"))
>>>>>>
>>>>>>doesn't work.
>>>>>>
>>>>>>If I use the POST method then it is reversed. Response.QueryString
>>>>>>doesn't get anything and the Session code works.
>>>>>>
>>>>>>Why is this? I can't seem to find an explanation in my ASP books.
>>>>>>
>>>>>>
>>>>>>
>>>>>When using method GET, you can access the form values via the
>>>>>Request.Querystring collection. When using method POST, you can access
>>>>>
>>>>>
>>>the
>>>
>>>
>>>>>form values via the Request.Form collection.
>>>>>
>>>>>
>>>>>
>>>>Why is that?
>>>>
>>>>Aren't they both forms? I would have thought that the Request.Form,
>>>>would still be able to get the data.
>>>>
>>>>I know that the difference between GET and POST is that you can see the
>>>>data that is passed in the URL line in your browser, but you can't in
>>>>the POST method.
>>>>
>>>>
>>>The method actually specifies which HTTP method is used to send the form
>>>[/color][/color]
> to
>[color=green][color=darkred]
>>>the processing agent. With the HTTP "get" method, the form data is
>>>[/color][/color]
> appended
>[color=green][color=darkred]
>>>to the URI specified by the action attribute, and this new URI is sent
>>>[/color][/color]
> to
>[color=green][color=darkred]
>>>the processing agent. With the HTTP "post" method, the form data is
>>>included in the body of the form and sent to the processing agent.
>>>[/color][/color]
> Thus,
>[color=green][color=darkred]
>>>with the "get" method, your form data is transferred to the querystring,
>>>[/color][/color]
> and
>[color=green][color=darkred]
>>>with the "post" method, it remains in the form.
>>>[/color]
>>
>>This is a "just curious" question as I understand now what "post" does,
>>but everyone says that the "post" method is appended to the form data
>>and then passed to the processing agent.
>>
>>In the "get" method, the URL/URI with the query string appended after
>>the "?" is sent to the processor. What is actually sent to the
>>processor for "POST"? When you say the body of the form with the form
>>data, are you talking about an HTML page that just has the form
>>information (no graphics,tables etc.).
>>[/color]
>
> When a form is submitted for processing, some controls have their name
> paired with their current value and these pairs are submitted with the form.
> Those controls for which name/value pairs are submitted are called
> successful controls.
>
> Read this section of the spec for more details regarding how form data is
> processed:
> http://www.w3.org/TR/html4/interact/...html#h-17.13.3
>
> In addition, you might read the relavent portions of the HTTP spec (section
> 9.5 for example):
> http://www.ietf.org/rfc/rfc2616.txt
>[/color]


That was what I was looking for (this and Marks comments).

Thanks,

Tom.

[color=blue]
>
>[color=green]
>>I assume the data somehow gets sent to the client for the browser to
>>handle. Where does the data get put for the client to handle for things
>>such as putting into cookies as well as putting on the screen?
>>[/color]
>
> Why would you assume such a thing??? Form processing occurs on the server,
> not on the client or browser. The server can tell the client that there is
> a cookie, and that is handled by each browser individually (as far as where
> is stores the cookie).
>
> The spec should answer most of your questions.
> Regards,
> Peter Foti
>
>
>[/color]

Closed Thread


Similar ASP / Active Server Pages bytes