Change sidebar on single post

Topics: Business Logic Layer, Controls, Themes
Jan 4, 2008 at 8:58 PM
I'm just starting out working with blogEngine ( It's really great Mads) and i'm looking for a way to determine from a sidebar control whether the current page being served is a single post or the home page. I can think of a few ways to get this information but it would take a bit of extra calling around the engine. Is there a property i'm missing that will easily tell me what type of page is being served? I see the ServingLocation enums but i'm not sure how to get the value from the post. Any help is appreciated, thanks for the great product!
Jan 5, 2008 at 2:59 AM
Edited Jan 5, 2008 at 3:01 AM
BlogEngine.Core.ServingLocation.SinglePost should do it.

private void Post_Serving(object sender, ServingEventArgs e)
if (!string.IsNullOrEmpty(e.Body))
// only process the posts
if (e.Location == ServingLocation.PostList || e.Location == ServingLocation.SinglePost)
Jan 5, 2008 at 11:43 AM

You could check the url. If a single post is displayed, "post.aspx" is called.

For example:
if (Request.Url.AbsolutePath.Contains("post.aspx"))
Jan 5, 2008 at 1:47 PM
Thanks to the both of you, I will take a look at this on Monday and let you know what the results are. Aschuc, your suggestion is what I was considering using and Rtur, yours is what I'm hoping (but unsure) will work in my scenario. Thanks again!
Jan 7, 2008 at 1:57 PM
aschuc, I was able to use your suggestion to accomplish my task.

if (!Request.Url.AbsolutePath.Contains("post"))
//Is single post

This worries me though because the URL structure might change in a future release. I'm unsure of how to hook into the Post_Serving event from my control. Rtur, do you have any suggestions on getting the Page ServingLocation from a user control on the page? I would prefer to use that method if possible.

Thanks again for your help!