Using hidden form fields to preserve state

M

Mark

Assume you have a web application with many different web pages, and you'd
like to avoid using cookies and storing session state in any form. Assume
further that bandwidth and security are not issues.

Could you conceivably store a serialized object containing state information
in a hidden form field, and pass it from page to page to page avoiding the
use of cookies and session data?

Thanks.

Mark
 
M

McGeeky

I was involved in a Java project that used this technique way back in 2000.
We serialized our objects in to XML, embedded them in a hidden form field,
and then desieralized when the page got posted.

The downside was that it meant the code behind every page having to do extra
work, also meant the pages could be quite big.

Upside was that there was no state stored in the session.
 
D

Darren Kopp

Yes it's possible, just make sure that all your objects are
serializable ([Serializable] attribute on all custom classes, then call
the serialize method). You will also need to get the data from the
field on the next page through Request.Form["key"] i believe.

HTH,
Darren Kopp
http://blog.secudocs.com/
 
E

Eliyahu Goldin

Mark,

You will want to use hidden fields only if the information you are putting
there is needed on the client side too. Otherwise you should use ViewState
as an alternative to session variables.

What do you mean by "passing from page to page"? From page A to page B, or
between the postbacks for the same page? If from page A to page B, do you
want to pass object on client side or on server side? If on server side,
hidden fields won't help you.

Eliyahu
 
S

Steven Cheng[MSFT]

Hi Mark,

As other members have mentioned, you can use html hidden form fields to
store some string data or serialized objects' content. However, for posting
from page to page ...., this is difficult. Are you using ASP.NET 2.0? If
so, it support cross page posting, however, this still require us to do
POST between pages so that the html form fields can be passed from original
page to target page.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top