Hi I am new to webdevelopment and i have just started to use episerver.
I was trying to use the Loginstatus LogoutPageUrl to redirect the user to another page after a logout. My problem is the LogoutPageUrl is working when set to a hard coded value but not when I am assigning using a method from the code behind.
This will return a string like http://localhost:port/en/ for the start page. I am not sure why this is not working, when I replace the LogoutPageUrl="<%=GetLoginUrl() %>"/> in the .ascx with LogoutPageUrl="http://localhost:port/en/" everything works.
Hi I am new to webdevelopment and i have just started to use episerver.
I was trying to use the Loginstatus LogoutPageUrl to redirect the user to another page after a logout. My problem is the LogoutPageUrl is working when set to a hard coded value but not when I am assigning using a method from the code behind.
Here is the code I am using:
<LoggedInTemplate>
<asp:LoginStatus ID="LoginStatus1" runat="server" LogoutText="LogoutTest" LogoutAction="Redirect" LogoutPageUrl="<%=GetLoginUrl() %>"/> </LoggedInTemplate>
The GetLoginUrl is returning a string which is formated after.
GetLoginUrl:
protected string GetLoginUrl()
{
PageReference loginPageRef = CurrentPage["EPEHome"] as PageReference;
if (loginPageRef != null)
{
EPiServer.UrlBuilder url = new EPiServer.UrlBuilder(DataFactory.Instance.GetPage(loginPageRef).LinkURL);
EPiServer.Global.UrlRewriteProvider.ConvertToExternal(url, null, System.Text.UTF8Encoding.UTF8);
string friendlyUrl = UriSupport.AbsoluteUrlBySettings(url.ToString());
return friendlyUrl;
}
//LoginView.Visible = false;
return string.Empty;
}
This will return a string like http://localhost:port/en/ for the start page. I am not sure why this is not working, when I replace the LogoutPageUrl="<%=GetLoginUrl() %>"/> in the .ascx with LogoutPageUrl="http://localhost:port/en/" everything works.
BR
Mattias