Try our conversational search powered by Generative AI!

Using asp:LoginStatus with LogoutPageUrl

Vote:
 

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() %>"/>
        <h1><%=GetLoginUrl() %></h1>
    </LoggedInTemplate>

 

<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

#46157
Nov 30, 2010 14:37
Vote:
 

Hi, you can't use <%= when giving a value to a webcontrol. Use <%# and databind the control and it should work.

#46168
Nov 30, 2010 18:00
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.