From 64c3227b3311e23dca7249fa95986a77cfd52bf3 Mon Sep 17 00:00:00 2001 From: ja Date: Thu, 16 Sep 2021 14:45:29 +0200 Subject: [PATCH] Logout Button wurde gefixed --- Customers/Customers.master | 11 +++-------- Customers/CustomsAviso.aspx | 21 ++++++++------------- login/Logout.aspx | 35 +++++++++++++++++++++++++++++++---- login/Logout.aspx.vb | 35 +++++++++++++++++++++++++++-------- newpageJulius_Sidebar.aspx | 6 ++---- newpageJulius_Sidebar.aspx.vb | 21 +++++++++++++++------ 6 files changed, 86 insertions(+), 43 deletions(-) diff --git a/Customers/Customers.master b/Customers/Customers.master index 0430854..00373fb 100644 --- a/Customers/Customers.master +++ b/Customers/Customers.master @@ -29,9 +29,7 @@ <%@ import Namespace="MySql.Data.MySqlClient" %> + + + -
+
- + <%If Me.Page.User.Identity.IsAuthenticated = False Then %> +

Du wurdest erfolgreich ausgeloggt.

+ + <%Else %> +

Du bist noch eingeloggt <%=Me.User.Identity.Name %>.

+ <%End If %>
+ + + + + + + + + + + + diff --git a/login/Logout.aspx.vb b/login/Logout.aspx.vb index 9e3a549..a3de093 100644 --- a/login/Logout.aspx.vb +++ b/login/Logout.aspx.vb @@ -1,14 +1,33 @@  +Imports System.Web.Configuration + Partial Class login_Logout Inherits System.Web.UI.Page - Protected Sub Page_Load(sender As Object, e As EventArgs) + + Dim sessionname + Sub Page_Load() Handles Me.Load + FormsAuthentication.SignOut() - Dim sessionname = Session.Item("lastpage").ToString - Session.Clear() 'clear session - Session.Abandon() 'Abandon session - Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1)) - Response.Cache.SetCacheability(HttpCacheability.NoCache) - Response.Cache.SetNoStore() - Response.Redirect(sessionname) + Session.Abandon() + + 'clear authentication cookie + Dim cookie1 As HttpCookie = New HttpCookie(FormsAuthentication.FormsCookieName, "") + cookie1.Expires = DateTime.Now.AddYears(-1) + Response.Cookies.Add(cookie1) + + 'clear session cookie (Not necessary for your current problem but i would recommend you do it anyway) + Dim sessionStateSection As New SessionStateSection + sessionStateSection = WebConfigurationManager.GetSection("system.web/sessionState") + Dim cookie2 As HttpCookie = New HttpCookie(sessionStateSection.CookieName, "") + cookie2.Expires = DateTime.Now.AddYears(-1) + + Response.Cookies.Add(cookie2) + Response.Redirect("../newpageJulius_Sidebar.aspx") + End Sub + + + Protected Sub btn_backtostart_Click(sender As Object, e As EventArgs) + Response.Redirect("../newpageJulius_Sidebar.aspx") + End Sub End Class diff --git a/newpageJulius_Sidebar.aspx b/newpageJulius_Sidebar.aspx index df25bf1..fc63daf 100644 --- a/newpageJulius_Sidebar.aspx +++ b/newpageJulius_Sidebar.aspx @@ -370,7 +370,6 @@ navParent = "admin.aspx" imgPath = "../" End If - Dim curentMenuId As String = "1" If Not Request.QueryString("menuID") Is Nothing Then curentMenuId = Request.QueryString("menuID") @@ -430,9 +429,8 @@ For Each nav3 As cNavigation In nav2.subnavigation If cells >= 3 Then %> - <% cells = 0 - End If - %> + <% cells = 0 + End If %> <%= nav3.bezeichnung %> diff --git a/newpageJulius_Sidebar.aspx.vb b/newpageJulius_Sidebar.aspx.vb index bb1d58a..595bc07 100644 --- a/newpageJulius_Sidebar.aspx.vb +++ b/newpageJulius_Sidebar.aspx.vb @@ -1,15 +1,24 @@  +Imports System.Web.Configuration + Partial Class _Default Inherits System.Web.UI.Page Protected Sub LogoutButton_Click(sender As Object, e As EventArgs) FormsAuthentication.SignOut() + Session.Abandon() - Session.Clear() 'clear session - Session.Abandon() 'Abandon session - Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1)) - Response.Cache.SetCacheability(HttpCacheability.NoCache) - Response.Cache.SetNoStore() - Session.Add("lastpage", "../newpageJulius_Sidebar.aspx") + 'clear authentication cookie + Dim cookie1 As HttpCookie = New HttpCookie(FormsAuthentication.FormsCookieName, "") + cookie1.Expires = DateTime.Now.AddYears(-1) + Response.Cookies.Add(cookie1) + + 'clear session cookie (Not necessary for your current problem but i would recommend you do it anyway) + Dim sessionStateSection As New SessionStateSection + sessionStateSection = WebConfigurationManager.GetSection("system.web/sessionState") + Dim cookie2 As HttpCookie = New HttpCookie(sessionStateSection.CookieName, "") + cookie2.Expires = DateTime.Now.AddYears(-1) + + Response.Cookies.Add(cookie2) Response.Redirect("login/Logout.aspx") End Sub End Class