This project is read-only.

BlogEngine.NET Place Recent Posts On Home page

Topics: ASP.NET 2.0, Controls
Jul 23, 2011 at 2:29 AM

I have 2.5 installed and it is working great but I have a problem I can't solve. It is installed in a virtual directory BlogEngine. I want to display a list of recent posts on the home page in the root directory I'm trying to use an ascx file to display it but I can't get it to work.

I have a test page set up that pulls the data and displays it fine. As long as both the RecentPosts.ascx and Test.aspx files are in the /BlogEngine directory everything works. But when I put the same code from the Test.aspx file in the index.aspx home page at the root it gives the error:

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Unknown server tag 'blog:RecentPosts'.

Source Error:

Line 7:  <div class="clearcontent"></div>
Line 8:  <div id="recentfront">
Line 9:  	<blog:RecentPosts runat="Server" />
Line 10: </div>

Source File: /BlogEngine/RecentPosts.ascx    Line: 9

This is the Code for the RecentPosts.ascx file:

<div class="wrapper row4">
<div id="content">
<div class="contentleft">
<h3>HR Help Hot News</h3>
<div class="clearcontent"></div>
<div id="recentfront">
 <blog:RecentPosts runat="Server" />

This is the Code for the Test.aspx file:

<%@ Page Language="C#" %>
<%@ Register TagPrefix="RecentPost" TagName="Recent" Src="RecentPosts.ascx" %>

<title>ASP.NET User Control Sample - Basic</title>
<body bgcolor="#FFFFFF">

<RecentPost:Recent runat="server" />


The above works perfectly.

Here's what I have tried:

In the code for the home page I changed the register line to:

<%@ Register TagPrefix="RecentPost" TagName="Recent" Src="~/BlogEngine/RecentPosts.ascx" %>

I also tried changing this line in the web.config file in the BlogEngine directory from this:

<!-- You can e.g. use "~/blog/" if BlogEngine.NET is not located in the root of the application -->
  <add key="BlogEngine.VirtualPath" value="~/" />

To this:

<!-- You can e.g. use "~/blog/" if BlogEngine.NET is not located in the root of the application -->
  <add key="BlogEngine.VirtualPath" value="~/BlogEngine/" />

But it still doesn't work. I'm sure it has to be something simple but I can't figure out what it is. Any help would be appreciated.




Jan 19, 2012 at 10:38 AM

Hi Richard,

 I was wondering did you get this sorted? I know it's been a good while since this was posted.

- This is the exact same issue I have, and have had with previous versions of BE. (I'm using v 2.5 now)

- I always end up integrating it into the root of the site which causes problems in it's own right.

- What is the simple solution (not an iframe), to display RecentPosts in a parent directory / root, when BE is installed as a child application / virtual directory?

Any pointers would be much appreciated.



Jan 19, 2012 at 2:47 PM
Edited Jan 19, 2012 at 3:36 PM

Try to put this code in your site master aspx file...

                        <ul class="recent_posts">
                                foreach (var post in BlogEngine.Core.Post.Posts.Where(post => post.IsVisibleToPublic).Take(Math.Min(5, rvisiblePosts.Count)))
                            <li class="clearfix">
                                <h3 class="title"><a href="<%=post.AbsoluteLink%>"><%=post.Title %></a></h3>
                            <% } %>


Let me know if it has worked or not..