Click here to Skip to main content
13,356,787 members (64,080 online)
Click here to Skip to main content
Add your own
alternative version


44 bookmarked
Posted 25 Apr 2008

Integrating a Blog into an ASP.NET 2.0 Web Site

, 8 Jul 2009
Rate this:
Please Sign up or sign in to vote.
How to integrate a blog into an ASP.NET 2.0 Web Site


Ok, so this is my first article. I've been wanting to write one forever, but always seem to be busy. As far as I know, no one has really written about this yet, but if so, can someone please let me know and send the links.

This article assumes that you are familiar with blogging ( to be specific), have a account, know how to use templates and template parameters, CSS and ASP.NET 2.0's Master Pages. For more information on how to create and write blogs using, please visit the Blogger homepage. For more information on using markup, e.g. <$BlogPageTitle$>, visit this site.


So what's this all about? Blogging. I have a couple of web sites, and and in an effort to get some more hits, I did a redesign as well as added a couple of blogs, one for site news, the other one for me to talk geek.

Now for ASP.NET, I haven't really seen any decent blogging software that was OpenSource except for BlogEngine.NET which I tried and it seems to work well. More recently I discovered Phill Haack's pet project SubText. It's not bad, but even Phil himself says he's trying to get a lot of what WordPress does into SubText. Looks like an interesting project though. I'm going to try and find some time and contribute to SubText.

The problem however was that I wanted to keep the same look and feel of my site for the blog, i.e. use my blogs with my master page. I thought about building my own blog/CMS to integrate into my site and didn't really feel like reinventing the wheel. I looked at somehow integrating BlogEngine.NET into my site, but that meant modifying BlogEngine.NET source. I found it hard to integrate into my existing site as it had its own masterpage and folder structure.

I already used for some other blogs and thought to myself, how can I use in my site? Sure I could use the APIs from Google, but I'm lazy and just want the blog working with the look and feel of my site. So... I just created a new blog on, and wrote some posts and added a little magic.

Using the Code lets you host your blog on their servers or you can host it on your own site. I opted to host it on my own site. To do this, you need to create the blog on through the advanced setup, here. In advanced setup, you will be asked for all your FTP information. If you need to know how to create a blog on using the advanced setup, visit the Blogger homepage. Once your blog is created, just write a test post, such as Hello World.

Here's where the magic happens. creates blogs using a template. Generally this template is good ol' CSS, HTML and some specific markup so that it can plug in stuff like the title of the post, post content, etc. So, by default, the template file is called index.html. I decided to call mine default.aspx.

As well there is an archive.html file for, you guessed it, the archives. I decided to call mine archive.aspx.

Now our blog will work and all the pages are *.aspx, so they go through ASP.NET now. Still not good enough though. I mentioned that I wanted to use the same look and feel as my entire site, so at the top of my default.aspx, I just put my page directive. Notice that the title attribute has a piece of markup. This will get transformed into the blog post title. If you want to learn what all the tags are, e.g. <$BlogPageTitle$>, visit this site.

<%@ page language="c#" masterpagefile="~/ric.master" Title="<$BlogPageTitle$>" %>

Now for the blog content, what I did was take an existing template on and used everything that was inside the <body> tag as the rest of the markup is in my master page. Here's a template I modified to use for my pages. This is where you need to know CSS and the templates. Using ASP.NET's OutputCache page directive is up to you. In my case, I can cache it as there is nothing dynamic on these pages ever, so the pages load faster.

<%@ OutputCache Duration="900" VaryByParam="none" %>
<%@ page language="c#" masterpagefile="~/ric.master" Title="<$BlogPageTitle$>" %>
<asp:Content ID="m" ContentPlaceHolderID="main" Runat="Server">
<link href="" type="text/css" rel="stylesheet" />  
<div id="content">
<h2>Site News</h2>
<div id="main"><div id="main2">
  <h2 class="date-header"><$BlogDateHeaderDate$></h2>
  <div class="post"><a name="<$BlogItemNumber$>"></a>
    <h3 class="post-title">
	 <BlogItemUrl><a href="<$BlogItemUrl$>" title="external link"></BlogItemUrl>
	         <div class="post-body">
    <p class="post-footer">
      <em><$I18NPostedByAuthorNickname$> <$I18NAtTimeWithPermalink$></em>
         <a class="comment-link" href="<$BlogItemCommentCreate$>"

		<$BlogItemCommentFormOnclick$>><span style="text-transform:lowercase">
<a class="comment-link" href="<$BlogItemPermalinkUrl$>#links">
	<span style="text-transform:lowercase"><$I18NLinksToThisPost$></span></a>
</MainOrArchivePage>  <$BlogItemControl$>
  <div id="comments">
	<BlogItemCommentsEnabled><a name="comments"></a>
    <dl id="comments-block">
        <dt class="comment-poster" id="<$BlogCommentAnchorName$>">
		<a name="<$BlogCommentAnchorName$>"></a>
        <dd class="comment-body">
        <dd class="comment-timestamp"><a href="<$BlogCommentPermalinkURL$>" 

		title="comment permalink"><$BlogCommentDateTime$></a>
		<p class="comment-timestamp">
    <p id="postfeeds"><$BlogItemFeedLinks$></p>
    <a name="links"></a><h4><$I18NLinksToThisPost$>:</h4>
    <dl id="comments-block">
        <dt class="comment-title">
        <a href="<$BlogBacklinkURL$>" rel="nofollow"><$BlogBacklinkTitle$></a> 
        <dd class="comment-body"><$BlogBacklinkSnippet$>
        <br />
        <span class="comment-poster">
        <em><$I18NPostedByBacklinkAuthor$> @ <$BlogBacklinkDateTime$></em>
    <p class="comment-timestamp"><$BlogItemBacklinkCreate$></p>
		<p class="comment-timestamp">
	<a href="<$BlogURL$>"><< <$I18NHome$></a>
<div id="sidebar"><div id="sidebar2">
<br />
  <h2 class="sidebar-title"><$I18NPreviousPosts$></h2>
    <ul id="recently">
        <li><a href="<$BlogItemPermalinkURL$>"><$BlogPreviousItemTitle$></a></li>
  <h2 class="sidebar-title"><$I18NArchives$></h2>
    <ul class="archive-list">
    	<li><a href="<$BlogArchiveURL$>"><$BlogArchiveName$></a></li>
<div style="text-align: center;">
<script type="text/javascript"><!--
google_ad_client = "pub-xxxxxxxxxxxxxxxxxxxxxx";
google_ad_host = "pub-xxxxxxxxxxxxxxxxxxxxxx";
/* 160x600, created 9/29/08 */
google_ad_slot = "1710078650";
google_ad_width = 160;
google_ad_height = 600;
<script type="text/javascript"

      <p id="powered-by"><a href="">
	<img src= 

	alt="Powered by Blogger" /></a></p>
      <p id="blogfeeds"><$BlogFeedsVertical$></p>

Republish the blog once your template has been changed and that's pretty much it. You have your site and a blog integrated into it with the same look and feel.

Points of Interest

  • The only problem I seem to have with this approach to blogging is that does not escape double quotes so the Title property for the Page directive gives a compilation error if you have double quotes in your title. Since I am aware of the issue, I just write my title using the double quotes entity &quot;.
  • Also, I'd like to be able to use the new's tag cloud control, but unfortunately, from what I read, it is only available for blogs that are hosted on So if you're looking to make a tag cloud, custom is the way to go.
  • I did this using ASP.NET but there's no reason why you couldn't take the same approach with PHP or another Web language.

I use but I have to say I still love WordPress when it comes to blogging/CMS. If I had more time, it'd be cool to create a WordPress.NET blogging/CMS port.


  • 22nd April, 2008: Article submitted


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer
Canada Canada
Web Guru / Crime Fighter

You may also be interested in...


Comments and Discussions

QuestionMessage Closed Pin
29-Oct-17 20:05
memberrosebk29-Oct-17 20:05 
QuestionMessage Closed Pin
29-Oct-17 20:05
memberrosebk29-Oct-17 20:05 
QuestionMessage Closed Pin
29-Oct-17 20:04
memberrosebk29-Oct-17 20:04 is Phasing out FTP Publishing Pin
nickyt3-Feb-10 7:52
membernickyt3-Feb-10 7:52 
Hey folks,

I just received this e-mail from Google explaining that their shutting down FTP publishing for See below. So looks like after mid-march, this article is obsolete. Thanks for all the comments and votes on the article.


"Dear FTP user:

You are receiving this e-mail because one or more of your blogs at are set up to publish via FTP. We recently announced a planned shut-down of FTP support on Blogger Buzz (the official Blogger blog), and wanted to make sure you saw the announcement. We will be following up with more information via e-mail in the weeks ahead, and regularly updating a blog dedicated to this service shut-down here:

The full text of the announcement at Blogger Buzz follows.
Last May, we discussed a number of challenges facing[1] Blogger users who relied on FTP to publish their blogs. FTP remains a significant drain on our ability to improve Blogger: only .5% of active blogs are published via FTP — yet the percentage of our engineering resources devoted to supporting FTP vastly exceeds that. On top of this, critical infrastructure that our FTP support relies on at Google will soon become unavailable, which would require that we completely rewrite the code that handles our FTP processing.

Three years ago we launched Custom Domains[2] to give users the simplicity of Blogger, the scalability of Google hosting, and the flexibility of hosting your blog at your own URL. Last year's post discussed the advantages of custom domains over FTP[3] and addressed a number of reasons users have continued to use FTP publishing. (If you're interested in reading more about Custom Domains, our Help Center has a good overview[4] of how to use them on your blog.) In evaluating the investment needed to continue supporting FTP, we have decided that we could not justify diverting further engineering resources away from building new features for all users.

For that reason, we are announcing today that we will no longer support FTP publishing in Blogger after March 26, 2010. We realize that this will not necessarily be welcome news for some users, and we are committed to making the transition as seamless as possible. To that end:

We are building a migration tool that will walk users through a migration from their current URL to a Blogger-managed URL (either a Custom Domain or a Blogspot URL) that will be available to all users the week of February 22. This tool will handle redirecting traffic from the old URL to the new URL, and will handle the vast majority of situations.
We will be providing a dedicated blog[5] and help documentation
Blogger team members will also be available to answer questions on the forum, comments on the blog, and in a few scheduled conference calls once the tool is released.

We have a number of big releases planned in 2010. While we recognize that this decision will frustrate some users, we look forward to showing you the many great things on the way. Thanks for using Blogger.


Rick Klau
Blogger Product Manager
1600 Amphitheatre Parkway
Mountain View, CA 94043


QuestionRe: is Phasing out FTP Publishing Pin
akbyrne19-Feb-10 10:49
memberakbyrne19-Feb-10 10:49 
AnswerRe: is Phasing out FTP Publishing Pin
nickyt24-Feb-10 10:04
membernickyt24-Feb-10 10:04 
GeneralRe: is Phasing out FTP Publishing Pin
Suhel Shah16-Jul-12 13:08
memberSuhel Shah16-Jul-12 13:08 
QuestionPublishing problem [modified] Pin
Member 352846429-Dec-09 0:39
memberMember 352846429-Dec-09 0:39 
AnswerRe: Publishing problem Pin
smith28830-Dec-09 7:54
membersmith28830-Dec-09 7:54 
AnswerRe: Publishing problem Pin
nickyt4-Jan-10 7:27
membernickyt4-Jan-10 7:27 
QuestionProblems Publishing my blog files to my web server. Pin
Member 352846415-Dec-09 2:23
memberMember 352846415-Dec-09 2:23 
AnswerRe: Problems Publishing my blog files to my web server. Pin
nickyt16-Dec-09 7:19
membernickyt16-Dec-09 7:19 
GeneralThanks a lot Pin
eslsys19-Nov-09 7:51
membereslsys19-Nov-09 7:51 
GeneralRe: Thanks a lot Pin
nickyt19-Nov-09 17:52
membernickyt19-Nov-09 17:52 
GeneralQuestion Pin
xc2k13-Nov-09 7:45
memberxc2k13-Nov-09 7:45 
GeneralRe: Question Pin
nickyt19-Nov-09 17:54
membernickyt19-Nov-09 17:54 
GeneralOkay, something is wrong Pin
Aptiva Dave14-Aug-09 6:19
memberAptiva Dave14-Aug-09 6:19 
GeneralRe: Okay, something is wrong Pin
nickyt14-Aug-09 6:32
membernickyt14-Aug-09 6:32 
GeneralRe: Okay, something is wrong Pin
Aptiva Dave14-Aug-09 8:00
memberAptiva Dave14-Aug-09 8:00 
QuestionRe: Okay, something is wrong Pin
Aptiva Dave15-Aug-09 16:31
memberAptiva Dave15-Aug-09 16:31 
QuestionNavigation menu in master page Pin
Aptiva Dave5-Apr-09 20:07
memberAptiva Dave5-Apr-09 20:07 
AnswerRe: Navigation menu in master page Pin
nickyt9-Apr-09 14:45
membernickyt9-Apr-09 14:45 
GeneralRe: Navigation menu in master page Pin
Aptiva Dave9-Apr-09 15:24
memberAptiva Dave9-Apr-09 15:24 
GeneralRe: Navigation menu in master page Pin
nickyt10-Apr-09 17:35
membernickyt10-Apr-09 17:35 
Generalliitle more clarification needed Pin
kennethdas19-Jun-08 20:04
memberkennethdas19-Jun-08 20:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.180111.1 | Last Updated 8 Jul 2009
Article Copyright 2008 by nickyt
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid