Cannot Delete Categories

Topics: ASP.NET 2.0, Business Logic Layer, Controls
Jan 18, 2012 at 7:41 PM

I have a blog created and have been testing out some of the features. I've noticed that I cannot delete categories from an Editor account but that I can from an account set up to be the admin. I've even tried giving every right to the Editor role and still cannot do it.

Clicking delete by a category takes me to the same page:
/Blog/admin/Posts/Categories.aspx
except it looks like the front end (themed) version of the blog instead of the admin, and I get the notice:

Ooops! An unexpected error has occurred.
This one's down to me! Please accept my apologies for this - I'll see to it that the developer responsible for this happening is given 20 lashes (but only after he or she has fixed this problem).

 

This happens no matter which user creates the category. I am unable to delete any while logged into an editor account.

Jan 20, 2012 at 3:38 PM

I've tried deploying the blog on different servers and different domains. For each of these I set up Editor level accounts with unique usernames/passwords. None of the editor level accounts are able to delete categories. Is there no fix for this?

Coordinator
Jan 20, 2012 at 7:15 PM
Edited Jan 20, 2012 at 8:28 PM

Under current rules only admin can delete categories. If you need to change this, unfortunately you'll have to make a change to BusinessBase.cs in the Core library and then re-compile and deploy BlogEngine.Core.Dll

Look for "public virtual SaveAction Save()" and then change from:

 

if (this.Deleted && !this.CanUserDelete)
{
	throw new SecurityException("You are not authorized to delete the object");
}

 

to:

 

if (this.Deleted && !this.CanUserDelete)
{
	if(!(Security.CurrentUser.IsInRole("Editors") && this.GetType().Name == "Category"))
		throw new SecurityException("You are not authorized to delete the object");
}
Feb 14, 2012 at 9:09 AM

This may sound noob but where can I find the BusinessBase.cs?

Coordinator
Feb 14, 2012 at 3:03 PM

What tools are you using?

Feb 15, 2012 at 12:58 AM

I'm running blogengine using webmatrix, but I also have a Visual Studio 2010 and an IIS Manager.

Coordinator
Feb 15, 2012 at 1:39 AM

If you installed BE with webmatrix, you got core library compiled and added to /bin directory as BlogEngine.Core.dll. To modify core library, you need download source version from "downloads" tab on this very page. Source code comes with C# project, search solution for code above, then modify and re-compile. Move new DLL to your site's /bin folder, and you should be set.

Feb 15, 2012 at 2:28 AM

Thank you for your help.. everything is working smoothly now. Thank you.