-1

Okay so I have an issue with my forms. I have a collection of forms on one page. The active one dynamically changes depending on the option you have selected. However my issue is that whenever a button is pressed in a form it logs out.

I'm not sure if it's resetting the session variables or not. But I also have the following in my Page Load method:

// Check if the user is logged in
if (!IsPostBack)
    if ((Convert.ToBoolean(Session["Check"]) == false) || Session["Check"] == null)
        Response.Redirect("/Login.aspx");

I'm at a complete loss as to why this is happening.

2
  • So...put a breakpoint on the third line and see if it fires?
    – Kirk Woll
    Commented Jun 11, 2013 at 2:32
  • you must be getting Session["Check"] as null of false.Chceck logic where Session is created. It might be on another page. Commented Jun 11, 2013 at 5:56

1 Answer 1

0
// Check if the user is logged in
object check = Session["Check"];

//acctually, you should probably take out the if !isPostBack.. 
//and always do the check
if (!IsPostBack && check == null || Convert.ToBoolean(check) == true)
{
    Response.Redirect("/Login.aspx");
}

First, do the null check first. If you were to write it this way, what is check? more specifically check the type of check in the debugger?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.