Session cleared after Redirect

J

John

Hi,

I do a Response.Redirect(page), and on the second page I have redirected to,
I get an object out of the session (or at least I attempt to). Just before
the redirect I do:

Session["token"] = tokenizer;

On the redirected page, in PageLoad I do:

Tokenizer tokenizer = (Tokenizer)Session["token"];

But the tokenizer is null, because the session is cleared. This is a
default web application, so I am not sure why it isnt working.

Any advice?

John.
 
J

John

Hi Mr Newbie,

I put the Tokenizer into the session using this:

Tokenizer tokenizer = new Tokenizer();
Session["token"] = tokenizer;

Later on I successfully get the tokenizer back from the session using:

Tokenizer tokenizer = (Tokenizer)Session["token"];

This code exists inside a web control, and all of it works fine. Only when
I access the session on the second page I immediately redirect to, is the
session cleared. I have tried to debug it, and literally on the line of the
redirect, the session contains my value, but doesnt once the new page is
loaded.

Any ideas?

Mr Newbie said:
Are you sure that tokenizer was not null before you saved it ?

John said:
Hi,

I do a Response.Redirect(page), and on the second page I have redirected
to, I get an object out of the session (or at least I attempt to). Just
before the redirect I do:

Session["token"] = tokenizer;

On the redirected page, in PageLoad I do:

Tokenizer tokenizer = (Tokenizer)Session["token"];

But the tokenizer is null, because the session is cleared. This is a
default web application, so I am not sure why it isnt working.

Any advice?

John.
 
J

John

Sorted it. It seems I have a label on the page, <asp:Label id="MyLabel"
runat="server/"> and the / is inside the server quoted text. The page
doesnt error, but the session is screwed....I think the parser should fail
this.

John.

Mr Newbie said:
Are you sure that tokenizer was not null before you saved it ?

John said:
Hi,

I do a Response.Redirect(page), and on the second page I have redirected
to, I get an object out of the session (or at least I attempt to). Just
before the redirect I do:

Session["token"] = tokenizer;

On the redirected page, in PageLoad I do:

Tokenizer tokenizer = (Tokenizer)Session["token"];

But the tokenizer is null, because the session is cleared. This is a
default web application, so I am not sure why it isnt working.

Any advice?

John.
 
M

Mr Newbie

yes it should really, well done for finding it anyway

Mr N

John said:
Sorted it. It seems I have a label on the page, <asp:Label id="MyLabel"
runat="server/"> and the / is inside the server quoted text. The page
doesnt error, but the session is screwed....I think the parser should fail
this.

John.

Mr Newbie said:
Are you sure that tokenizer was not null before you saved it ?

John said:
Hi,

I do a Response.Redirect(page), and on the second page I have redirected
to, I get an object out of the session (or at least I attempt to). Just
before the redirect I do:

Session["token"] = tokenizer;

On the redirected page, in PageLoad I do:

Tokenizer tokenizer = (Tokenizer)Session["token"];

But the tokenizer is null, because the session is cleared. This is a
default web application, so I am not sure why it isnt working.

Any advice?

John.
 

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,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top