0

when i click on logout button, everything will be fine after that click on back button of browser user does not enter or login ..thats also good.(but, no event click on master pages; working is good )

and, any event is clicked like search items (i mean using select query or fetch data through button click)

logout button working not good ...its work like normal page ;i.e. when i click on logout ...redirect to home page using Session.clear(); & Redirect.Response("page.aspx")

Use this code,behind master page page_load:

if (!IsPostBack)
        {

            if (Session["name"] == null)
            {

                Response.Redirect("Default.aspx");
            }

            else
            {

                Response.ClearHeaders();

                Response.AddHeader("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate");

                Response.AddHeader("Pragma", "no-cache");

                Label1.Text = "WELCOME" + " " + Session["name"];


            }

now i want to disabling back button without using of javascript, because reason is when someone stop the javascript of browser ....same issues occurs..

John Saunders
  • 160,644
  • 26
  • 247
  • 397
user1534477
  • 51
  • 2
  • 5
  • question is messy, I would suggest to use this tricks http://msmvps.com/blogs/jon_skeet/archive/2010/08/29/writing-the-perfect-question.aspx – Arsen Mkrtchyan Aug 27 '12 at 08:52
  • 1
    private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here if (Session["SessionId"] == null) { Response.Redirect("Login.aspx"); } Response.Buffer=true; Response.ExpiresAbsolute=DateTime.Now.AddDays(-1d); Response.Expires = -1500; Response.CacheControl ="no-cache"; } – Shipu Aug 27 '12 at 09:16
  • Remove if (!IsPostBack) condition and check. Hopefully will work for you and and its also helpful to make your app more secure. – Sami Aug 27 '12 at 09:52
  • Refer this solution http://stackoverflow.com/a/28458499/2089963 – Syed Mohamed Feb 11 '15 at 15:53

1 Answers1

2
private void Page_Load(object sender, EventArgs e)
    {
        // Put user code to initialize the page here
        if (Session["SessionId"] == null)
        {
            Response.Redirect("Login.aspx"); 
        }


        Response.Buffer=true;
        Response.ExpiresAbsolute=DateTime.Now.AddDays(-1d);
        Response.Expires = -1500;
        Response.CacheControl ="no-cache";

    }
Esha
  • 391
  • 1
  • 9
  • 37
Shipu
  • 543
  • 14
  • 27