Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Automatic Logout Page View modes: 
User avatar
Member
Member
jdsharp - 1/14/2013 10:35:36 AM
   
Automatic Logout Page
I'm working on building an ASPX page in CMSModules/MyModule/LogoutUser.aspx that when loaded will automaqtically call CMSContext.LogoutUser(); and then redirect them to another URL.

What's happening is Kentico is intercepting our redirect call and displaying the Kentico Login Page. I've tried both Response.Redirect and URLHelper.Redirect which both have the same result.

(On the landing page, no authentication is selected for security)

Below is the code from the ASPX page:
protected void Page_Load(object sender, EventArgs e)
{
if (RequestHelper.IsPostBack())
return;

if (CMSContext.CurrentUser.IsAuthenticated())
{
CMSContext.LogoutUser();
}

CMSContext.CurrentUser = null;

var redirectUrl = URLHelper.GetQueryValue(Request.Url.AbsoluteUri, "redirectUrl");

Response.Cache.SetNoStore();
URLHelper.Redirect(string.IsNullOrEmpty(redirectUrl) ? "/" : redirectUrl);
}

Cheers,
- Jonathan

User avatar
Member
Member
jdsharp - 1/15/2013 8:51:33 AM
   
RE:Automatic Logout Page
I was able to resolve the issue. It ended up being the redirectUrl parameter that was URL encoded and wasn't being automatically URLDecoded. Once I decoded it the redirect worked perfectly.

- Jonathan

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 1/21/2013 5:29:33 AM
   
RE:Automatic Logout Page
Hi Jonathan,

Thank you very much for the additional info, I hope it will help also somebody else in the feature. Well done!

Best regards,
Martin Danko