locked
banking web application ,restrict user to go back to previous page RRS feed

  • Question

  • User547991737 posted

    hello guys ,

    i need to make bank application ,if user logins thne he will not be able to go back to previous Pages and if he do so than  i will logout him , i dont want to use java script functions of history etc. , security is my main concern i can use session but , i dont know how to start.


    Wednesday, August 12, 2009 11:49 AM

Answers

  • User-481631678 posted

    YOu can add these tags in your <head> section of the page. This will re-load page if you press back button.

    <meta http-equiv="Pragma" content="no-cache" />
        <meta http-equiv="Expires" content="-1" />

    Alternetavely you can write these lines in your code behnid file to achieve the same.


    Response.Cache.SetCacheability(HttpCacheability.NoCache);  
    Response.Cache.SetExpires(DateTime.Now);

    To denhy un authroized access, You can create a BasePae class which inherits System.Web.UI.Page. Override the OnInit method and write appropriate code in that which will redirect to default page.

    public class BasePage : System.Web.UI.Page
    {
     protected override void OnInit(EventArgs e)
        {
      if(Session["UserName"]==null)   
             {
        Response.Redirect("~/Login.aspx"); 
        }


    Response.Cache.SetCacheability(HttpCacheability.NoCache);   //These lines are added so every page do not allow back button.
    Response.Cache.SetExpires(DateTime.Now);
     }
    }

    And inherit all your ASPX pages from BasePage class, instead of System.Web.UI.Page like this:-


    public partial class HomePage :BasePage   
    {  
            protected void Page_Load(object sender, EventArgs e)  

     {
      
     }  

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 12, 2009 12:37 PM
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 12, 2009 12:40 PM

All replies

  • User-481631678 posted

    YOu can add these tags in your <head> section of the page. This will re-load page if you press back button.

    <meta http-equiv="Pragma" content="no-cache" />
        <meta http-equiv="Expires" content="-1" />

    Alternetavely you can write these lines in your code behnid file to achieve the same.


    Response.Cache.SetCacheability(HttpCacheability.NoCache);  
    Response.Cache.SetExpires(DateTime.Now);

    To denhy un authroized access, You can create a BasePae class which inherits System.Web.UI.Page. Override the OnInit method and write appropriate code in that which will redirect to default page.

    public class BasePage : System.Web.UI.Page
    {
     protected override void OnInit(EventArgs e)
        {
      if(Session["UserName"]==null)   
             {
        Response.Redirect("~/Login.aspx"); 
        }


    Response.Cache.SetCacheability(HttpCacheability.NoCache);   //These lines are added so every page do not allow back button.
    Response.Cache.SetExpires(DateTime.Now);
     }
    }

    And inherit all your ASPX pages from BasePage class, instead of System.Web.UI.Page like this:-


    public partial class HomePage :BasePage   
    {  
            protected void Page_Load(object sender, EventArgs e)  

     {
      
     }  

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 12, 2009 12:37 PM
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 12, 2009 12:40 PM