How to pass value of one page to another page

R

Rabbit

Hi,

On my 1st page, i have a function which gets a new ID value and need to
transfer to another immediately.

which I want to get in 2nd page using Request.form("txtID"), but doesn't
work, the returned value is ""

Anybody know how to set this value on 1st page properly, in order to let 2nd
page catch it? I don't want to use querystring to pass this value!

Thanks in advance!
Keith
 
S

Steve C. Orr [MVP, MCSD]

Here's another nice, simple way to pass values from one page to another:
(VB.NET code)

'Add data to the context object before transferring
Context.Items("myParameter") = x
Server.Transfer("handle_error.aspx ")

Then, in handle_error.aspx.aspx:

'Grab data from the context property
Dim x as Integer = CType(Context.Items("myParameter"),Integer)

Of course there are a number of ways to pass values from one page to another
besides the querystring there are cookies, session, context, saving to a
temporary table in the database between each page, etc.
You'll have to decide which technique is best for your application.

Here are more good articles on the subject:
http://SteveOrr.net/faq/PassValues.aspx
http://www.aspalliance.com/kenc/passval.aspx
http://msdn.microsoft.com/msdnmag/issues/03/04/ASPNETUserState/default.aspx
 
J

Jose Rodriguez

In addition to all of the methods that Steve enumerated, in 2.0 there is a
new feature called cross-page posting where your form and the values of it
get posted to a subsequent page. HTH

Jose
 
R

Rabbit

Thanks Steve

Its working, but I have another problem, if the user clicks my SiteMapNode
to jump to another page, since the menu item is hyperlink, so i can't use
your suggested method to pass data to another page

If I can't use Cookies, session, and i don't want too much work by using
database. Any other method you can tell me for pass data to another page by
clicking hyperlink on the source page?

Thanks in advance
 
S

Steve C. Orr [MVP, MCSD]

I gave a long list of other potential techniques you could use.
How about you investigate using Session state. It should be one of the
simpler solutions.
 
R

Rabbit

I can't use Session state, because currently we notice IIS's 6.0 worker
process (w3wp.exe) has memory leakage problem, at some point when it recycle
the process, all session state will be clear, so connected user will lost
those information.

thats why I want to pass variable data between form without using Session
state method!

Any alternative?
 
S

Steve C. Orr [MVP, MCSD]

OK then try cookies, or a database, etc.




Rabbit said:
I can't use Session state, because currently we notice IIS's 6.0 worker
process (w3wp.exe) has memory leakage problem, at some point when it
recycle the process, all session state will be clear, so connected user
will lost those information.

thats why I want to pass variable data between form without using Session
state method!

Any alternative?
 
M

Mark Rae

I can't use Session state, because currently we notice IIS's 6.0 worker
process (w3wp.exe) has memory leakage problem, at some point when it
recycle the process, all session state will be clear, so connected user
will lost those information.

?????

Is this a known issue? First I've heard of it...
 
R

Rabbit

I can 100% sure w3wp.exe has leakage problem when using Crystal Report for
..net (the one comes with VS.Net)

Recently we found that memory usage goes up at constant rate (2MB in our
case) for report execution, after a while when the memory usage goes up to
around 200MB, Crystal Report Viewer will return Load Report Failed

I was using the most typical way to run the report, so I can conclude this
problem was due to w3wp.exe because when I kill this service(the downside is
all session will be cleared), the Crystal Report execution will work again.
 
L

Laurent Bugnion

Hi,

Mark said:
?????

Is this a known issue? First I've heard of it...

The memory leakage problem is probably due to bugs in the programming.
We conducted extensive tests on IIS5 and IIS6 and we also had memory
leaks in the beginning, but by using tools and with Microsoft's
assistance, we now have a very stable situation.

The recycling is an option which you can use in IIS6 only, you can set a
time after which the working process will be restarted. It's not an
issue, it's a feature, however it's correct that you'll lose your
session state when the process is recycled. Since the process is stopped
cleanly (meaning that the ApplicationEnd event will be executed), you
can implement a way to persist the session state to a file, for example,
and then reload it on ApplicationStart. Since the session IDs remain the
same (because SessionID depends on the client, not on the server), it's
quite easy to do that if needed.

HTH,
Laurent
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

It's possible that you have found an actual bug in the system, but it's
far more likely that there is a bug in your code.

There are thousands of people that has used the same setup before you,
and if there was a leak like that in IIS or Crystal Report, there would
be a lot to read about it.
 
R

Rabbit

Laurent,

Thanks for your suggestion! Sounds this is the way out, do you mind to give
me more detail (such as sample coding) about how to do it? especially how to
you retrieve/save the same Session ID when the Application_End and
Application_Start

Because, the current web application on production already, I need to find a
solution to fix up the problem as soon as possible!

Thanks in advance

Because I thought Session ID will be different everytime when
 
L

Laurent Bugnion

Hi,
Laurent,

Thanks for your suggestion! Sounds this is the way out, do you mind to give
me more detail (such as sample coding) about how to do it? especially how to
you retrieve/save the same Session ID when the Application_End and
Application_Start

Because, the current web application on production already, I need to find a
solution to fix up the problem as soon as possible!

Thanks in advance

I'll try to post an example tonight, so you can try it tomorrow.

HTH,
Laurent
 
R

Rabbit

Laurent,

Thanks very much for your suggestion, I did use your idea and change my code
today and so far its under testing and working fine at the moment!

In summary, I did use following design to keep the session info:
a) When user logon, I used current session ID to create a filename at Web
Server, which stores Logon and some user account information
b) At each page's Load event, check if session gets lost, use session ID to
locate the file, in order to reinitialize Session items and copy them into
ViewState for web page function reference.
c) I have provide Logout function for user to end the session and my system
will delete the session file for user

So using above design, even the worker process has recycled while other user
working, their session value can still be keep for continue working!
 
L

Laurent Bugnion

Hi,
Laurent,

Thanks very much for your suggestion, I did use your idea and change my code
today and so far its under testing and working fine at the moment!

In summary, I did use following design to keep the session info:
a) When user logon, I used current session ID to create a filename at Web
Server, which stores Logon and some user account information
b) At each page's Load event, check if session gets lost, use session ID to
locate the file, in order to reinitialize Session items and copy them into
ViewState for web page function reference.
c) I have provide Logout function for user to end the session and my system
will delete the session file for user

So using above design, even the worker process has recycled while other user
working, their session value can still be keep for continue working!

That sounds good. Note that to be safe, you should also plan the case
where the session is never ended correctly (because the user doesn't
log-off, and because the server crashes before the SessionEnd event is
executed). There are different approaches to that problem, the easiest
being to delete the files when they are older than X days.

HTH,
Laurent
 
R

Rabbit

Yes, forgot to mentioned that I will run a batch a mid-night, which kills
any session file created older than 2 days!
 

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,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top