Why BlogEngine 2.0 append any <p> tag with <br /> tag on my home page?

Topics: ASP.NET 2.0, Business Logic Layer
Dec 3, 2010 at 11:15 PM
Edited Dec 3, 2010 at 11:18 PM

Why BlogEngine 2.0 append any <p> tag with <br /> tag on my home page? It doesn't do it when I open some particular post, but it do this for every post on main page. How to fix it?

UPDATE: see http://podlipensky.com as an example.

Dec 4, 2010 at 2:13 AM

Do you have any custom Extensions running?  An extension has the capability of changing the markup as the post is being served ... and it can optionally do this only when the post is being served on the home page.  If you do have any custom extensions, I would try disabling them to see if it makes a difference.

Dec 4, 2010 at 4:19 AM


I've tried to disable all widgets/extensions I have and the problem still was there. Also I noted that it appears only on main page and only if descriptions shown on main page (not whole posts). Then I investigated your code and finally I found the cause of the bug:

PostViewBase.cs, line 51:

body = post.Description.Replace(Environment.NewLine, "<br />") + link;

Please release patch for it.


Dec 4, 2010 at 5:26 AM

Glad you found that.

The "Description" (aka Excerpt) is a plain text field (textarea) on the Add Entry page, located below the main WYSIWYG editor.

Are you pasting in HTML into the "Description" field?  It is designed to hold plain text -- not HTML.  The typical usage for it is to enter 2 or 3 "unformatted" sentences into the box.   That code is actually correct for its intended usage.  It replaces newlines in "plain text" with <br /> tags.

If you're trying to show an "HTML" excerpt on the homepage, you might want to consider using the [more] functionality -- instead of Description/Excerpt.  In the main WYSIWYG editor, enter [more] where you want the post to cut off.  [more] will be replaced with a "more" link that the person can click on to view the full post.  This functionality is possible via the "BreakPost" extension.