02-20-2018 08:53 AM
Hi everyone,
We are implementing a Geospatial Portal 2016 EP04 solution that is using a custom ASP.NET membership provider for authentication. Once the user is logged in we would like to add a function to the Geospatial Portal template that a user can use to log out.
We can't use the Log Out option from the Authentication tab for two reasons.
Does anyone have recommendations on how we could allow a user to log out of the application and be passed back to the login screen (LoginForm.aspx) or another URL (e.g. redirect to the home page of the solution we are building).
Thanks,
Colin
Solved! Go to Solution.
02-22-2018 04:42 AM
Hi Colin,
How about a simple button with link to an ASPX page (combination of JS and .NET code) that will take care of the session, cookies and then redirect to LoginForm.aspx?
Regards,
Jan
02-22-2018 04:44 AM
We've not done this type of work before. Can you share any JS and .NET code samples for clearing session and cookies?
02-22-2018 05:12 AM
Actually, with form authentication, this is as simple as it could be
Create Logout.aspx file:
<%@ Page Language="C#" AutoEventWireup="True" CodeFile="Logout.aspx.cs" Inherits="Logout" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" runat="server"> <head runat="server"> <title>Logging out...</title> </head> <body> <form id="form1" runat="server"> </form> </body> </html>
Create Logout.aspx.cs
using System; using System.Web; using System.Web.Security; public partial class Logout : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { FormsAuthentication.SignOut(); Response.Redirect("LoginForm.aspx"); } }
Then, for example, add a button to the toolbar by placing this into your custom JS file that is referenced in ASPX:
$GP.ready(function () { $GP.ui.toolbar.add({ categoryIndex: 0, xtype: "tbbutton", text: "Logout", handler: function (b) { window.location.replace("Logout.aspx"); } }); });
03-06-2018 08:56 AM
Thanks for your suggestion Jan. It clears the session correctly ensuring a user cannot get back into the web application without entering valid credentials again.