How to Create logout page asp.net with c#


How to Create logout page asp.net with c# Logout code in asp.net c# for admin which have master page. I want to secure code for logout when click on logout button. I was try many code for logout but can't success. In many codes after click on logout button and press beck button of browser then again go in page.

  1. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="logout.aspx.cs" Inherits="logout" %>

    <!DOCTYPE html>

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
               <div>
        
                 </div>
            </form>
         </body>
    </html>


source code:-


  1. using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    public partial class logout : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Session.Clear();
            Session.RemoveAll();
            Session.Abandon();
            Response.Redirect("~/login.aspx");
        }

    }

Post a Comment

0 Comments