Saturday, October 25, 2008
more work on the blogs
still getting long-outstanding things done here:
- finally fixed the dates on the images in the gallery. they have been screwed up since the original migration to community server two years ago
- fixed search operation from blog pages (was only working from aggregate & other pages). gotta be careful with the order of things in siteurls.config when placing blogs at the site root
- fixed a strange bug where if a blog post name or number is referenced and doesn’t exist, a page with all the comments from that blog is returned – !
that last one is really a problem with the <CSBlog:WeblogFeedbackList /> control, but never mind that, i don’t even want the post page showing up at all – why isn’t a 404 generated ?
so i created post404.ascx in the blog theme folder:
<%@ Control Language="C#" %>
<%@ Import Namespace="CommunityServer.Controls" %>
<%@ Import Namespace="CommunityServer.Components" %>
<script runat="server">
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
Post post = CSContext.Current.GetCurrent<Post>();
if ( post == null || ( post.PostID == 0 && String.IsNullOrEmpty(post.Name) ) )
throw new System.Web.HttpException( 404, "" );
}
</script>
and added the following
<%@ Register TagPrefix="CSUserControl" TagName="Post404Check" Src="Post404.ascx" %>
...
<CSUserControl:Post404Check runat="server" />
in the blog theme’s post.aspx page. that last part is at the beginning of the first asp:Content tag’s contents.
what i don’t like is that the 404 page comes up with aspxerrorpath set to the rewritten path of the page, rather than the external form. couldn’t find anything on changing that while still preserving the 404 error code.