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