Session not working

G

Guest

For some reason my Session state stopped working in my webpages. I cannot
pass a variable from one webpage to another using the Session. For example:

Web page 1:

Session["filepath"] = dbname;
Response.Redirect("Webpage2");

Webpage 2:

protected string filepath;
private void Page_Load(object sender, System.EventArgs e)
{
filepath = (Session["filepath"]).ToString();

I receive the following message when the above instruction is reached
"Object reference not set to an instance of an object."
Can anyone tell me why this is happening? This has been working for 2 years
and now it is not! Some environmental variable must have changed but what?
 
G

Guest

are the pages in the same application, depending on the IIS application
protection setting session may not be shared across applications
 
G

Guest

Yes. The pages are in the same application. This system has been running
for 2 years and I really don't know what I could have done to make the
Sessions stop sharing.

mikegellis said:
are the pages in the same application, depending on the IIS application
protection setting session may not be shared across applications
--
mg


Parrot said:
For some reason my Session state stopped working in my webpages. I cannot
pass a variable from one webpage to another using the Session. For example:

Web page 1:

Session["filepath"] = dbname;
Response.Redirect("Webpage2");

Webpage 2:

protected string filepath;
private void Page_Load(object sender, System.EventArgs e)
{
filepath = (Session["filepath"]).ToString();

I receive the following message when the above instruction is reached
"Object reference not set to an instance of an object."
Can anyone tell me why this is happening? This has been working for 2 years
and now it is not! Some environmental variable must have changed but what?
 
D

Damien

Parrot said:
For some reason my Session state stopped working in my webpages. I cannot
pass a variable from one webpage to another using the Session. For example:

Web page 1:

Session["filepath"] = dbname;
Response.Redirect("Webpage2");

Webpage 2:

protected string filepath;
private void Page_Load(object sender, System.EventArgs e)
{
filepath = (Session["filepath"]).ToString();

I receive the following message when the above instruction is reached
"Object reference not set to an instance of an object."
Can anyone tell me why this is happening? This has been working for 2 years
and now it is not! Some environmental variable must have changed but what?

Is the code in Web page 1 new, and are you using normal sessions
(rather than cookieless)?

There are some issues with setting up a new session and then
immediately redirecting, using the default cookie sessions, since
ASP.Net can't set the cookie and send the redirect simultaneously, so
it throws the cookie away and you get a new session on the second page.

Damien
 
G

Guest

There is no new code in webpage 1. That is why I am perplexed as the Session
was working. I checked for Session.IsCookieless and it is false. Does that
mean anything? I don't understand how to differentitate between a normal
session and a cookieless session. Is that something I can control with
parameters?

Damien said:
Parrot said:
For some reason my Session state stopped working in my webpages. I cannot
pass a variable from one webpage to another using the Session. For example:

Web page 1:

Session["filepath"] = dbname;
Response.Redirect("Webpage2");

Webpage 2:

protected string filepath;
private void Page_Load(object sender, System.EventArgs e)
{
filepath = (Session["filepath"]).ToString();

I receive the following message when the above instruction is reached
"Object reference not set to an instance of an object."
Can anyone tell me why this is happening? This has been working for 2 years
and now it is not! Some environmental variable must have changed but what?

Is the code in Web page 1 new, and are you using normal sessions
(rather than cookieless)?

There are some issues with setting up a new session and then
immediately redirecting, using the default cookie sessions, since
ASP.Net can't set the cookie and send the redirect simultaneously, so
it throws the cookie away and you get a new session on the second page.

Damien
 

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