Log Out button?

Topics: Controls, Themes
Nov 23, 2011 at 11:50 PM

Hi guys, I am having some problems with the authentication system used by blogengine.

 

I am an asp.net developer my self, but I usually use FormsAuthentication for this.

 

What I did was, I used a LoginStatus control, like so:

 

                    <asp:LoginStatus ID="LoginStatus" runat="Server" LoginText="Log in" LogoutText="Log out"
                        EnableViewState="false" LoginImageUrl="~/themes/MyTheme/img/LoginButton.jpg"
                        LogoutImageUrl="~/themes/MyTheme/img/LogoutButton.jpg" 
                        onloggingout="LoginStatus_LoggingOut" />

The login part works, but when I click log out, the page doesn't do anything. It just does a postback and return to the homepage.

I tried:


    protected void LoginStatus_LoggingOut(object sender, LoginCancelEventArgs e)
    {
        FormsAuthentication.SignOut();
    }

But it doesnt work.

I must be doing something wrong here... please help :).

Thanks

Coordinator
Nov 24, 2011 at 3:57 AM

You can use code from standard theme:

<a runat="server" id="aLogin" /

Then in the form behind:

if (Security.IsAuthenticated)
{
	aLogin.InnerText = Resources.labels.logoff;
	aLogin.HRef = Utils.RelativeWebRoot + "Account/login.aspx?logoff";
}
else
{
	aLogin.HRef = Utils.RelativeWebRoot + "Account/login.aspx";
	aLogin.InnerText = Resources.labels.login;
}

Nov 24, 2011 at 6:42 PM

Thanks man