Session is null when redirect after login

Viewed 47

This is where the registration is checked

    protected void BtnLogin_Click(object sender, EventArgs e)
    {
        this.user = new User();

        DAL dal = new DAL();
        user = dal.GetUserDetails(this.a.Text, this.b.Text;);
        Session["Login"] = user; //here
        Session.Timeout = 25;
        Response.Redirect("Default.aspx");
    }

The routing goes here

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["Login"] == null)//Sometimes it is NULL and sometimes it is full
            {
                Response.Redirect("login.aspx");
            }

        }
    }

*If I close and reopen VS, it works (vs 2022)

Why does the SESSION suddenly not work on another page?

On the same page it does exist and has not been deleted

0 Answers
Related