This project is read-only.

Delete Post Navigate URL

Topics: ASP.NET 2.0, Controls
Jul 27, 2009 at 4:52 PM

Hi all, I was wondering if there was a method of altering the redirect URL when a post is deleted using the AdminLinks?

At the moment I seem to be getting some inconsistent behaviour - probably a result of my own doing. Specifically, when an Administrator is logged in, clicking the Delete link on a post takes me back to default.aspx (and the post gets deleted). However, when an Editor is logged in, clicking the Delete link on a post takes me to the post page with the query string "/post/<title here>?deletepost=..." (and the post does not get deleted).

Any ideas why this may be happening?

Jul 28, 2009 at 3:06 AM
Edited Jul 28, 2009 at 3:07 AM

No worries, located the problem. I guess others may also come across this? The problem is in the OnPreInit method on the BlogBasePage page (BlogEngine core). Specifically, in the following if condition :

Page.User.IsInRole(BlogSettings.Instance.AdministratorRole) || Page.User.Identity.Name == post.Author)

the equality comparison between Page.User.Identity.Name and post.Author was returning false for my non-admin user because one of those properties was returning my username with a capital first letter, whereas the other was returning the entire name in lowercase. So I made that part of the condition case insensitive (calling ToLower on the returned names).