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

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

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??
Nov 17 '05 #1
3 9382
PJ
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.
"Jessica Loriena" <jl******@hotpop.com> wrote in message
news:9b**************************@posting.google.c om...
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??

Nov 17 '05 #2
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.

"PJ" <pj*********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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.
"Jessica Loriena" <jl******@hotpop.com> wrote in message
news:9b**************************@posting.google.c om...
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??


Nov 17 '05 #3
Does anyone have a comment on my approach for using ASP.Net forms and
page redirecting below?

jl******@hotpop.com (Jessica Loriena) wrote in message news:<9b*************************@posting.google.c om>...
So, from I understood, the best approach for my problem in ASP.Net would be:

*******
form.aspx

If IsPostBack Then
If Validation is OK Then
Store form variables in Session variables
Store form variables in database
Response.Redirect("welcome.aspx")
End If
End If

<form runat="server">
...
</form>
*******
welcome.aspx

- Show form values using previously stored Session variables
Please correct me if I'm wrong, or if there's a better way...

Thanks for your replies!


"Jessica Loriena" <jl******@hotpop.com> wrote in message
news:9b**************************@posting.google.c om...
> 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??

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Morten | last post by:
Hi! I've been implementing forms based authentication in a web project. It works pretty good. When I log on by clicking the "login" button the following code is executed: if...
6
by: Scott Zabolotzky | last post by:
I'm trying to pass a custom object back and forth between forms. This custom object is pulled into the app using an external reference to an assembly DLL that was given to me by a co-worker. A...
6
by: Girish | last post by:
so asp.net does not allow you to change the action of a form to another page other than itself (if your using form runat=server). This is by design. So what is the best way to pass values between...
6
by: Jon | last post by:
If a session times out, but the forms auth is still logged in it's possible for users to go to pages on the site that need those session variables. I was under the impression that using forms auth...
5
by: Max | last post by:
Hi All! I'm doing an ASP.NET project which uses Persistent Forms Authentication (i.e. once user logged in, they don't have to log in again). However Session variables are erased after Session...
5
by: Schultz | last post by:
I am having two problems in the application I am building, the first has to do with forms authentication. The application has three different login pages: 1- for admins 2- for users 3- for...
15
by: Sandy | last post by:
My background is web based. I am attempting to write a Windows application and I am finding some simple things difficult. Currently I am trying to find out how to store information session wide....
0
by: MirkoGeest | last post by:
(Webmaster: sorry, I posted this first at the General Software Engineering category, but I think this goes here) I'm using Visual Basic with Web Forms on .NET 2003 and I'm experiencing a very...
16
by: sebastiangarth | last post by:
I need to be able to make a variable persistent between page invocations without submitting a form or sending it as a name-value pair in the URL. Another requirement I have is that I can't store...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.