New to ASP.Net forms (and Session variables??)

  • Thread starter Thread starter Jessica Loriena
  • Start date Start date
J

Jessica Loriena

I'm trying to write a simple "register form / validate and store in
database / show welcome screen" application with ASP.Net. With
conventional ASP, I used Session variables and it went something like
this:

*****
form.asp

- <form action="ValidateAndStore.asp" method="post">

*****
ValidateAndStore.asp

- Pass form values into Session variables.

- If validation OK Then
Store in database
redirect("welcome.asp")
Else
redirect("form.asp?error=ValidateError")
End If

*****
welcome.asp

- Show form values using previously stored Session variables


I know there are no need for Session variables in ASP.Net forms
because the state is preserved. All tutorials and books I've read so
far show how to post ASP.Net forms to itself (post back), but how do I
validate and redirect to *another* page without losing the form
variables??? Do I have to use Session variables again even with
ASP.Net forms??
 
you are free to Response.Redirect all you want in asp.net...i think the
difference is that instead of accessing/parsing the form post variables
directly, you will get the data from the controls that contain the data,
much like a windows form. State is preserved on the controls for that page
via the ViewState....if you need specific data outside of the current form,
then you are free to use Session state, the asp.net Cache object, or query
your db for specific data in the form.

IMO, asp.net does not discourage the use of Session...in fact, i believe
it's a great way to store data in objects as opposed to the only real option
of primitive types in classic asp.
 
Using the Session is certainly appropriate in many cases. ASP.Net provides a
larger number of caching options. It's just a matter of determining the most
appropriate caching mechanism to use according to the requirements of the
part of the app which you are building. Sessions provide a method of storing
data in memory across multiple pages for a single client, for the duration
of that client Session. This functionality is not provided by other caching
mechanisms. If that is the functionality needed, by all means, use it.

It is important to familiarize yourself with the various caching mechanisms
available, in order to make the best choice in any given situation.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Complex things are made up of
lots of simple things.
 
Does anyone have a comment on my approach for using ASP.Net forms and
page redirecting below?
 
Back
Top