Hexagon Geospatial
MENU

Developer Discussions

Discuss topics with other Hexagon Geospatial Power Portfolio developers and experts to get the most out of our products.
Showing results for 
Search instead for 
Do you mean 
Reply
Regular Contributor
Posts: 246
Registered: ‎10-26-2015
Accepted Solution

Geospatial Portal - Log Out Function

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.

  1. The Authentication tab allows the editing of the account email address and password and this doesn't work with our ASP.NET membership provider.
  2. The Log Out button on the Authentication tab doesn't reload the web application.

 

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

Technical Evangelist
Posts: 1,034
Registered: ‎09-11-2015

Re: Geospatial Portal - Log Out Function

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

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Regular Contributor
Posts: 246
Registered: ‎10-26-2015

Re: Geospatial Portal - Log Out Function

We've not done this type of work before. Can you share any JS and .NET code samples for clearing session and cookies?

Highlighted
Technical Evangelist
Posts: 1,034
Registered: ‎09-11-2015

Re: Geospatial Portal - Log Out Function

Actually, with form authentication, this is as simple as it could be Smiley Happy

 

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");
        }
    });
});
Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Regular Contributor
Posts: 246
Registered: ‎10-26-2015

Re: Geospatial Portal - Log Out Function

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.

Do you need immediate support?
Please submit a Ticket through our
Development Ticket Portal.