Cannot start the website because administrative privileges are required to bind to the hostname or port

This error was thrown when I ran the newly downloaded BlogEngine.NET code from Visual Studio 2015.
First thing first, this has got nothing to do with ‘Run as administrator‘ option. The error states that there is a permission issue on the port on which IISExpress was attempting to run the site. I hadn’t changed anything to the original code base. So it was apparent that the port setting must have got imported. My understanding was that Visual Studio auto manages this setting, i.e., if the attempted port is busy, then VS automatically finds the next available slot. As it turned out, this is not the case.

 
Anyways, the solution is to remove the old references of the url (IISUrl) and the port (DevelopmentServerPort) from the csproj file. Apparantly, if you don’t provide any specific url & port, Visual Studio will automatically look for an available port. Yes! automatic.

Following are the steps to accomplish the same:

  • First, ensure that, ‘Apply server settings to all users (store in project file)‘ is checked.
  • From the Solution Explorer in Visual Studio, right click the web project and select ‘Unload Project‘.
  • Next on the same project, right click and select ‘Edit‘.
  • Find the xml tags and and remove them.
  • Reload the project and run.
As you can see in the address bar, the site’s running and is doing so on a different port.

Recover your lost Admin password of BlogEngine [2.8]

If you have lost your BlogEngine’s admin password then, there’s a quick cheat. If you’re using xml to store data (which is the default) then open App_Data/users.xml file. You can now see all the users with their password in encrypted format. Replace the admmin user’s password with the following (without the double quotes)

jGl25bVBBBW96Qi9Te4V37Fnqchz/Eu4qB9vKrRIqRg=

Now log in for this user with the password as “admin” (without the double quotes)
Once logged in, you can then reset the password.

More Info …

Thanks …

Sort the BlogEngine Page-List Widget [2.8]

 

 

 

Problem

This one is for the sorting of Pages in the BlogEngine 2.8 Page-List widget. By default, the sorting of the pages in the list was in the alphabetic order. However, I wanted to sort the page list in custom way. Unfortunately, there is no control/option for sorting the page-list widget.

Solution

To sort the page list in custom order you’ll have to write a bit of code.

Open App_Code/Controls/PageList.cs file.
Look for the BindPages() method in it.
Replace the existing code with the following:-


List<BlogEngine.Core.Page> pagesList = new List<BlogEngine.Core.Page>();
var varPagesList = BlogEngine.Core.Page.Pages.OrderBy(p => p.DateCreated);
pagesList = varPagesList.ToList<BlogEngine.Core.Page>();

var ul = new HtmlGenericControl("ul") { ID = "pagelist" };
ul.Attributes.Add("class", "pagelist");

foreach (var page in pagesList.Where(page => page.ShowInList && page.IsVisibleToPublic))
{
	var li = new HtmlGenericControl("li");
	var href = page.RelativeLink;
	if (BlogSettings.Instance.RemoveExtensionsFromUrls && !string.IsNullOrEmpty(BlogConfig.FileExtension))
	  href = href.Replace(BlogConfig.FileExtension, "");

	var anc = new HtmlAnchor { HRef = href, InnerHtml = page.Title, Title = page.Description };

	li.Controls.Add(anc);
	ul.Controls.Add(li);
}

return ul;

Now the Page inside that widget will be listed according to their created date field. We can easily modify this field to put a page at the top or at the bottom of the list. To do that, you have to open  App_Data/pages xml-files . These xml files are the description of your pages in the blog. If you open it you will get the created date property there which you can easily modify. A snapshot of one of my page is give below for better understanding.

Thanks …

JQuery Nivo Slider v2.0 not Showing Up in BlogEngine 2.8

Problem

Actually problems were multiple but, in this blog I will only focus on the Nivo Slider’s integration to BlogEngine.Net. I installed the NivoSlider from the Gallery option of the BlogEngine.Net. The installation was successfull and I could see the NivoSlider in the Installed Extension’s option.

After that I went through their tutorial and without doing any custom modification I wrote the following code in one of my post, more info


[SLIDER:slider1]

After saving the post, I navigated back to the front page. However, nothing appeared except for an edit link. Now, when I checked the Console in my Google Chrome browser, I saw the error that the method LoadSlider is undefined.

Solution

It was clear that the somehow the webpage is not getting the reference of the nivo-slider-js. So to add it’s reference I added the following code inside my theme page body section


<link type="text/css" rel="stylesheet" href="<%=Utils.AbsoluteWebRoot %>Styles/nivo-slider.css" />
<script type="text/javascript" src="<%=Utils.AbsoluteWebRoot %>Scripts/jquery.nivo.slider.pack.js"></script>

Now the slider was showing up in all the posts it had been plugged in.

Note

There’s one more thing I must mention here i.e, if you are integrating NivoSlider 2.0 with BlogEngine 2.8 then the slider may not work properly. The reason is that NivoSlider uses the live method of jQuery and as of jQuery 1.7, the .live() method is deprecated.

To resolve the issue, open the file jquery.nivo.slider.pack and rename the .live() method to .on().
Click here for more info

That’s it!!