how to avoid from going back to login page from home page on refresh C#


234 просмотра

1 ответ

This is my Login page

This is my master.aspx page.(Red Mark showing Login.aspx becouse i used server.transer)

If i refresh the page my page goes back to the login page. I used " Session.Abandon();, Session.Clear();" in Login.aspx.cs page and

        if (!IsPostBack)
            if (Session["LoginId"] == null)
                Response.AddHeader("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate");
                Response.AddHeader("Pragma", "no-cache");

in Master.aspx.cs page..Help me to solve this.

Автор: Jayant Kumar Источник Размещён: 08.11.2019 10:57

Ответы (1)

0 плюса

So do you ever add a value in the LoginId? or do you always check if it is null which causes to redirect to the login page. You said you clean the session so i assume your session is empty after you log in. Also refresh the page is different from !IsPostBack. PostBack is when you click on a web control, not when you refresh, so that cause the LoginId = null which is never set and it always go to Login.aspx! I would suggest to verify the user on the login page and set the LoginId to some value, also your master code is kinda messy because it will cause the header to clean and repopulate multiple times when you fix the LoginId issue.

Автор: Stelios Размещён: 20.08.2016 08:07
Вопросы из категории :