A simple open-source ASP.NET MVC blog

Are you ready to launch?

JustBlog is an open-source blog application built using ASP.NET MVC. It brings you the following exciting features.

→ Admin panel to manage posts, categories and tags

→ Disqus commenting system integration

→ AddThis and FeedBurner integration

→ ELMAH error log page

→ Contact page

Home Page

Home Page

I've attached the published version of JustBlog along with this post. You can also download from Github. I haven't decided the license type yet. You are allowed to copy, modify and use the source code to build your own blog. But, you are not allowed to sell any product that is built using the original or modified source code.

If you have already bought a domain it's fine else you can buy using GoDaddy or any other domain service provider out there. Having just a domain is not enough, you've to decide where you are going to host it. There are lot of hosting providers available. Before choosing the hosting provider make sure they support windows hosting plan with .NET framework 4.5 and ASP.NET MVC 4. Also make sure they provide support for SQL Server 2010 or 2012.

If you have the domain and hosting ready, you can launch your own blog in just 8 steps!

"8" steps to set bring your blog live!

All the changes said below has to be done only in the web.config file which is located in the root folder.

The following are the eight steps you have to do. Are you ready?

  1. Create database and tables
  2. Set Disqus short name
  3. Set AddThis url
  4. Set Feedburner url
  5. Set admin login credentials
  6. Set Timezone
  7. Email settings
  8. Final things

1. Create database and tables

I've used JustBlog with SQL Server 2010 and 2012. Most of the website hosting companies provide you an admin panel to manage your databases.

You've to do the following things to complete this step.

a. Create database in your server and update connection string
b. Execute script to create core tables
c. Execute script to create ELMAH tables

a. Create database in your server and update connection string

Once you created the database in your hosting server you've to update the "connectionString" attribute in <connectionStrings> section in web.config.

			<connectionStrings>
				<add name="JustBlogDbConnString" 
					connectionString="Data Source=SERVER_IP;Initial Catalog=DATABASE_NAME;User Id=USER_ID;Password=PASSWORD;"
					providerName="System.Data.SqlClient"/>
			</connectionStrings>
		

You should replace the SERVER_IP, DATABASE_NAME, USER_ID and PASSWORD variables with your database info.

b. Execute script to create core tables

To create the JustBlog application domain tables you've to run an SQL script. You can download the script from here.

c. Execute script to create ELMAH tables

We are using ELMAH library to log errors into database. To create the tables and SPs required for ELMAH you have to run the SQL script provided by ELMAH which you can download from here.

2. Set Disqus short name

We have used the awesome Disqus commenting system to exchange comments. When you register your site with Disqus you should have to specify a "short name". I recommended in my article to specify your domain name as the short name. You've to enter that short name in the value attribute of the "Domain" key which is under <appSettings>.

			<appSettings>
				...
				
				<add key="Domain" value="DISQUS_SHORT_NAME"/>
				...
			</appSettings>
		

3. Set AddThis url

We have used AddThis to share blog posts through different social networks. At the time of registration, they will ask you to copy a piece of code snippet that will render the AddThis widget in your website. The code snippet contains html and script references as shown below.

			<div class="addthis_toolbox addthis_default_style addthis_32x32_style">
				<a class="addthis_button_preferred_1"></a>
				<a class="addthis_button_preferred_2"></a>
				<a class="addthis_button_preferred_3"></a>
				<a class="addthis_button_preferred_4"></a>
				<a class="addthis_button_compact"></a>
				<a class="addthis_counter addthis_bubble_style"></a>
			</div>
			<script type="text/javascript">var addthis_config = {"data_track_addressbar":true};</script>
			<script type="text/javascript" src="http://s7.addthis.com/js/300/addthis_widget.js#pubid=ra-519360bf195ef191"></script>
		

Copy only the url specified in the "src" attribute of the <script> tag (i.e. http://s7.addthis.com/js/300/addthis_widget.js#pubid=ra-519360bf195ef191) and paste it to the value attribute of the "AddThis" key.

			
			<add key="AddThisUrl" value="ADDTHIS_URL" />
		

4. Set Feedburner url

JustBlog generates RSS feed for subscription. By registering this feed to Google's Feedburner, subscribers are kept upto date with the latest blog content. At the time of registration, you are asked to enter the feed url of the blog which is http://YOURBLOGDOMAIN/feed. Feedburner, finally return you another url (something like http://feeds.feedburner.com/YOURBLOGDOMAIN) through which your feed can be subscribed easily. Copy that url and paste it into the value attribute of the "FeedBurnerUrl" key.

		    
			<add key="FeedBurnerUrl" value="FEEDBURNER_URL" />
		

5. Set admin login credentials

You can specify more than one administrator for your blog (who have the rights to add/edit blog posts using the admin page). You should enter the details of those admin users under the <credentials>. [Note: The url to access admin page is http://YOURBLOGDOMAIN/admin]

			<authentication mode="Forms">
			  <forms loginUrl="~/Login" timeout="2880">
				<credentials passwordFormat="Clear">
				  <user name="ADMIN1" password="PASSWORD1" />
				  <user name="ADMIN2" password="PASSWORD2" />
				  ...
				</credentials>
			  </forms>
			</authentication>
		

Based upon the configured admin users, you should update the <authorization> node of the <location path="elmah.axd"> section to allow access to the EMLAH error log. For example, if you have added "ADMIN1" and "ADMIN2" then the <authorization> section should be.

			<authorization>
				<allow users="ADMIN1"/>
				<allow users="ADMIN2"/>
				<deny users="*"/>
			</authorization>
		

The error log is accessed by the url http://YOURBLOGDOMAIN//elmah.axd.

6. Set Timezone

You have to specify a timezone to format a post's published datetime. To specify the timezone, you've to update the "Timezone" and "TimezoneAbbr" keys. The application persists datetimes in UTC format so you can change the timezone at anytime safely. To know the list of timezones visit this page.

			<add key="Timezone" value="India Standard Time" />
			<add key="TimezoneAbbr" value="IST" />
		

7. Email settings

Emails are used at two places in JustBlog: contact page and ELMAH. ELMAH alert admin by sending emails whenever some exception happens in the application. Check your hosting plan whether they provide email options else you have to buy it separately. You have to specify the server name, username, password and port details of the SMTP server as part of the email settings.

a. Configure SMTP settings

You should enter the SMTP details under the <system.net> section.

			<system.net>
				<mailSettings>
				  <smtp>
					<network host="HOST_ADDRESS" userName="USER_NAME" password="PASSWORD" port="PORT" />
				  </smtp>
				</mailSettings>
			</system.net>
		

You should replace the HOST_ADDRESS, USER_NAME, PASSWORD and PORT with relevant values.

b. Configure email settings in ELMAH

You have to specify proper values for "from", "to" and "smtpServer" attributes in the <errorMail> section. Note that, you can use same email address at both the places.

			<errorMail from="EMAIL_FROM_ADDRESS"
					   to="EMAIL_TO_ADDRESS"
						subject="Exception occured in JustBlog"
						priority="High"
						async="true"
						smtpServer="SMTP_SERVER"
						useSsl="false"
						noYsod="true" />
		

c. Specify admin email address

Whenever user tries to contact you regarding anything like questions, issues through the contact page, an email will be sent to the admin. To configure the admin email address you have to update the "AdminEmail" key under <appSettings> section. It's fine to use single email address in all the above places.

8. Final things

You should update some more keys in the <appSettings> section to specify your blog title, description, author and other things for SEO, Social Connections etc.

			<add key="BlogTitle" value="[Enter your blog domain name. Ex. JustBlog]" />

			<add key="BlogDescription" value="[Describe your blog in one sentence. Ex. A Technical blog, where I write interesting things about many subjects.]" />

			<add key="BlogUrl" value="[Enter your blog url. Ex. http://www.justblog.com]" />

			<add key="MetaKeywords" value="[ex. Enter  blog technical]" />

			<add key="MetaDescription" value="[Could be same as 'BlogDescription'] />

			<add key="Author" value="[Author name. Ex. Vijaya Anand]"/>

			<add key="Twitter" value="[Twitter url]"/>

			<add key="Facebook" value="[Facebook page]"/>

			<add key="Pininterest" value="[Pininterest url]"/>
		

Please update the "value" attribute in all the above keys with the appropriate values. You should also need to update the "About Me" page based on your profile and interest.

Admin Urls

Admin page - http://YOURDOMAIN/admin
ELMAH error log - http://YOURDOMAIN/elmah.axd

Before you leave...

I thank all the readers who exchanged good comments in my three part series. Their comments helped me to improve the source code very much. I'm really looking forward for more feedback, suggestions and advices to improve JustBlog and make it more useful to others.

download justblog now! fork in github