How To Remove "Log In" Menu Item From BlogEngine.net Site



TODO:

Have you ever wanted to remove the log in link that is in the menu of sites created with BlogEngine.Net?

 

SOLUTION:

Download the source for BlogEngine.Net.  

Open in Visual Studio

Open BlogEngine.Net\App_Code\Controls\PageMenu.cs

Look for the method "HtmlGenericControl BindPages()"

Comment out "AddMenuItem" in the ELSE of the Security.IsAuthenticated check.

Build the solution, and deploy the new DLL.

Now you will never see "log in", and will see "log off" only if you login by going directly to the log ing page.  ( yoursite.com/Account/Login.aspx )

 

 

private HtmlGenericControl BindPages()
{
            // recursivly get all children of the root page
            HtmlGenericControl ul = GetChildren(Guid.Empty);

            // items that will be appended to the end of menu list
            AddMenuItem(ul, Contact, "~/contact.aspx");

            if (Security.IsAuthenticated)
            {
                AddMenuItem(ul, Logoff, "~/Account/login.aspx?logoff");
            }
            else
            {
                //AddMenuItem(ul, Logon, "~/Account/login.aspx");
            }

            return ul;
}

 

 

NOTES:

There are no notes on this topic



Comments (4) -

Ahmad
Ahmad
8/19/2013 7:38:31 PM #

How can i do this with the last version as there is no BindPages just render control ?

Donnie Wishard
Donnie Wishard
8/20/2013 9:27:36 AM #

Ok, it appears that is in the BlogEngine.Core.Web.Controls.PageMenu.cs file.  If you download the 2.8 source, and go to the BlogEngine.Core project, you will see the Web\Controls\ folder.  Open up the PageMenu.cs file and you will see the BindPages() method.  Just change there, build the solution, and use that version of the Core dll.  That will fix it up for you.

Ahmad
Ahmad
8/20/2013 7:10:02 PM #

It worked for me Laughing
who is the man ?
you are the man Laughing
so thanks man

Donnie Wishard
Donnie Wishard
9/6/2013 5:42:02 PM #

Glad it worked!

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading