Loosing session variables in redirect

G

Guest

I am developing my web apps on a Win XP Pro SP2 laptop and then uploading
them to a Windows Server 2003. My current project involves using session
state variables to keep track of user after they have logged in. The
login.aspx page contains the following code:

if(sAuthorized != "-1" && sAuthorized != "-2")
{
Session["user"] = sAuthorized;
Response.Redirect("index.aspx");
}

Then the index.aspx page contains the following code in the page load event:

string sUserID = Session["user"].ToString();

Now, everything works fine on my laptop, but when I try to run it on the
server I get an "Object reference not set to an instance of an object" error
when it tries to set sUserID equal to the session variable. Any suggestions
would greatly be appreciated. Thanks.
 
G

Guest

I suppse that condition is never met, so to go over this problem add just for
a test an else clausule and assign something to session["user"] variable.
Then, read on the redirected page once again this value.
 
G

Guest

Of course I assume, that you have cookies enabled in Browser and Session
State is enabled on server machine...
 

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

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top