Are you looking to set up a Blog on your existing asp.net website and have finalized BlogEngine Dot Net, then this article will help you
do the set up.
For those who do not know, it is an open source blog application written in asp.net and C#. It can be easily
integrated with your current website to provide the blog (writing articles) facility to your website users. You
can go throught he BlogEngine website to know about the featrues it supports.
We also use the same Blog application to power our community on this site here.
BlogEngine 2.0 can be used independently or can be integrated with your exisitng website. We are
going to talk about the integration with existing website.
Download BlogEngine 2.0
It can be downloaded from here. The current version of BlogEngine is 2.5 but we are using 2.0 as
version 2.5 has some issues with existing website integration and hence we also have not moved on to it yet.
We are using the BlogEngine.NET 2.0 (Web) version.
If you want to play with the BE code or want to customize it, you should download the SRC code zip.
Convert BE to work on asp.net 4.0 and IIS 7.0
The BE 2.0 is built on asp.net 3.5. But if your existing website is running on asp.net 4.0, you can easily
port BE 2.0 to work on asp.net 4.0 too.
No need to make any special adjustments, just follow the steps and
it should be good to work on asp.net 4.0. No need to mention that your existing website should already be running
on asp.net 4.0.
If you use Godaddy.com to host your website, you may like to follow the instructions here to set up asp.net 4.0 in Godaddy for your exsiting website..
Integration with existing asp.net 4.0 website
- Set up Blog in a subfolder:
The best and clean approach of using Blog is to keep all
the code related to blog in a separate subfolder under your root website. For example, if your website code is
placed at YOURWEBSITE.com (called root), then we should set up blog at
YOURWEBSITE.com/Blogs. The word Blogs can be anything of your choice.
So,
create a folder Blogs in your website's root.
YOURWEBSITE.com or
~/ --> Stores all your website code. May contain some other folders too.
YOURWEBSITE.com/Blogs/ or ~/Blogs/ --> Stores all your BE 2.0 code.
- Unzip BE 2.0 and copy to existing website:
Unzip the BlogEngine.NEt (Web) code that
you have downloaded. The file structure would look something like this:
BlogEngine.NET 2.0 (web)
\BlogEngine.Web[All Files and folders]
Copy all files and folders from above
path to YOURWEBSITE.com/Blogs folder. This brings all BE 2.0 code to your existing website and
need some folder movements to make it work.
- Move [App_*] folders to Root:
Copy (Copy and paste) all [App_*] folders from
YOURWEBSITE.com/Blogs/ to YOURWEBSITE.com. If you already have these folders in
your existing website, you can safely add the BE contents in same folders.
BE 2.0 would have following
folders that need to be copied: App_Code, App_GlobalResouces, App_Data. Please remember that you should NOT copy App_Data folder. if you are upgrading BE from earlier BE installation.
- Move Bin folder to Root:
Move (Cut and paste) Bin folder from
YOURWEBSITE.com/Blogs to YOURWEBSITE.com. If you already have this folder in
your existing website, you can safely add the BE bin's contents in it.
- Create Database (Optional):
BE can run on databse or XML store. If you want to run it
on a database, you should follow this step else you can skip it. BE supports multiple DB's like MySQL, MS SQL
server etc.You may already have a database in your existing website. I would advise you to create a new one to
keep things separate and clean. Right click 'App_Data' folder, select 'Add New Item'->'SQL Server Database'
and to create a new SQL server DB for storing blog data.
Once done with your DB, create the DB schema using the SQL script available in ~\Blogs\setup folder.
Choose your Db and it contains the necessary script and run it your DB manager to create table schema.
- Merge web.config files of existing website and BE 2.0:
This is the most important and
time consuming part of integration.
Open the existing website's web.config file from ~/ and make the following changes step by
step:
- Find following tag
< configuration > < configSections >
and add the following line
(If it contains another tags, let them be there. Don't delete):
- Find following tag
< configuration >
and add the following line (If it contains another
tags, let them be there. Don't delete):
Please not that this entry is for specifying the data store mechanism for BlogEngine. If you are using the
database to store BE data, change the defaultprovider value to DbBlogProvider. Example:
<blogProvider defaultProvider="DbBlogProvider">
- Find following tag
< connectionStrings >
and add the following line (If it contains another
tags, let them be there. Don't delete):
The connectionString in above tag should point to the database which you created in above steps. If you are
not using database to store BE data, you can skip this tag entry.
- Find following tag
< appSettings >
and add the following line (If it contains another tags,
let them be there. Don't delete):
The BlogEngine.VirtualPath i.e. folder where Blog code resides should be ~/Blogs
- Find following tag
< system.web >
< compilation >
< assemblies >
and add the following line (If it contains another tags, let them be there. Don't delete):
NOTE: These tag may already exist in your web.config. If any one of them is already there, don't add another one.
- Find following tag
< system.web >
< compilation >
< expressionBuilders >
and add the following line (If it contains another tags, let them be there. Don't delete):
NOTE: The expression builder tag may not be available in your existing web.config. If it is not there, you can
add one for yourself inside < system.web > < compilation >
- Find following tag
< system.web >
and add the following line/s (If it contains another tags, let them be there. Don't delete):
NOTE: These tag may already exist in your web.config. If any one of them is already there, don't add another one.
- Find following tag
< system.web >
< httpHandlers>
and add the following line (If it contains another tags, let them be there. Don't
delete):
- Find following tag
< system.web >
< httpModules >
and add the following line (If it contains another tags, let them be there. Don't
delete):
- Find following tag
< system.web >
< pages >
< controls >
and add the following line (If it contains another tags, let them be there. Don't
delete):
- Find following tag
< system.web >
and add the following line (If it contains another tags, let them be there. Don't delete):
- Find following tag
< system.webServer > < modules > :
and add the following line (If
it contains another tags, let them be there. Don't delete):
- Find following tag
< system.webServer > < handlers > :
and add the following line (If
it contains another tags, let them be there. Don't delete):
- Existing Asp.net membership and BE:
If you already have existing membership (user
registration and login/log out functionality) enabled in your existing website, then you do not need any other
settings now. You are done. But if you don't have any or want to switch to BE's membership, you should add
following tags for it:
- Find following tag
< system.web >
and add the following line (If it contains another tags,
let them be there. Don't delete):
system.web>
NOTE: This tag may already exist in your web.config. If it is already there, REPLACE it with the above one.
- Find following tag
< system.web >
and add the following line (If it contains another tags,
let them be there. Don't delete):
system.web>
NOTE: These tags may already exist in your web.config. If they are already there, REPLACE them with the above
ones.
Also, if you are using database, enable the DbMembershipProvider instead of XmlRoleProvider.
Wow..we are done with merging the web.config files. The toughest battle has been won.
- Disable or Delete config file in Blogs:
Since we have merged the BE configuration with
existing website, we should delete the config files given in YOURWEBSITE.com/Blogs. This file
should be either excluded from project or deleted:
web.config
- Set up Blog to compile:
Ideally, all BE 2.0 code should reside
~/Blogs/ folder but there are some places where it tries to find some folders in the root(~/)
itself and throws an error if not found. To remove these errors, make following movements:
- Copy some folders in root (~/) :
Copy and paste admin, Account, Scripts, Styles, themes and widgets folders from ~/Blogs/
to ~/ .
- Move (Cut and paste) some files to root (~/) :
Copy and paste web.sitemap and Global.asax file from ~/Blogs/ to ~/ . If your
website root already contains global.asax file, then you should merge the two to avoid any collisions.
- Write permission on App_Data folder:
Make sure that you have write permissions on App_Data folder for BE to store data.
- Run:
You should now run the BE installation by launching the
~/Blogs OR YOURWEBSITE.com/Blogs
. This will open the
~/Blogs/Default.aspx page.
If you can see the welcome message (welcome blog post), your set up has succeeded.
That is it. Good luck. If you face any issues, ask in comments and i will be glad to help you.