This project is read-only.

Installing BlogEngine.NET in an existing website

Topics: ASP.NET 2.0, Business Logic Layer, Themes
Jan 16, 2011 at 8:55 AM
Edited Jan 16, 2011 at 10:38 AM

Well, according to Ben Amada's answer at I have two choices.

Converting blog and current site into one application is very very messy. specially when dealing with themes/css.

So I have decided to go with the IIS option.

The problems:

1- ASP.Net membership/profile/roles: Guess this is the easiest one. Same Connectionstring in both web.configs + same ApplicationName + same MachineKey makes them use the same membership/profile/role provider. (Or at least I think it does)

2- I'd like to be able to communicate with the blog. e.g. show latest posts on my site's first page or in general show dynamically generated stats of the blog in my site: how about adding reference to BlogEngine.Core? Is it possible to communicate with it from my site to get blog-specific info? Or is it going to need some initialization from web.config/etc?

3- Plus, I'd like to provide the same look and feel (theme) for my site and my blog. (blog's master page is same as my site's master page): How can I set blog's master page to my site's masterpage when they're not in the same application?

Should I provide my own methods to communicate with DB and get the stats and design a specific masterpage in the blog application and set it to blog's master page? Or can I somehow communicate with the blog from my site although they're different apps. (e.g. set the blog's masterpage from my site, access blog widgets in my site, ...)

Apologies for the lengthy question.

Jan 16, 2011 at 7:02 PM

Actually, I'm planning to integrate BlogEngine with another application. It's messy, but going IIS route is also messy.

I've been experimenting with membership/roles. I managed to make it work for ClientWindowsAuthenticationMembershipProvider and XmlRoleProvider. If you want to use the same providers for two applications, there are certain complications. For example roles created in one of them don't appear  in another until you restart the other. Besides, you might in fact want the roles to be separate in two applications.  

Anyway, I'll keep you updated on my progress with the single app route.


Jan 16, 2011 at 7:29 PM

Thanks. I'd appreciate it neuromancer. 

Anyone has any info about the other two problems?

Jan 16, 2011 at 10:47 PM

Regarding the second problem - how about using BlogML

Jan 17, 2011 at 5:40 AM

Hmm, that's a good idea. never thought about that...

Jan 17, 2011 at 10:22 AM


I made some progress on with one app. I managed to make the basics work, admin pages don't work. I had to tweak XmlRoleProvider in the process.

Guess, you've reached this point as well.

If you'd like to discuss the details, please feel free to contact me at

Jan 17, 2011 at 11:56 AM
Edited Jan 17, 2011 at 12:27 PM

Solution to problem 1:

Root web.config:

There are 3 zones you should modify:

1- Add 'Name' attribute to 'forms' node:
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" name=".MYAPP" timeout="2880" defaultUrl="~/default.aspx" cookieless="UseCookies" protection="All" slidingExpiration="true"/>

2- Define machienkey:
<machineKey validationKey="D9F7287EFDE8DF4CAFF79011D5308643D8F62AE10CDF30DAB640B7399BF6C57B0269D60A23FBCCC736FC2487ED695512BA95044DE4C58DC02C2BA0C4A266454C" 
decryptionKey="BDAAF7E00B69BA47B37EEAC328929A06A6647D4C89FED3A7D5C52B12B23680F4" validation="SHA1" decryption="AES"/>
Note: you can use this online machinekey generator tool to generate your custom machine key.
3- Define Membership/Role Providers:
<membership  defaultProvider="AspNetSqlMembershipProvider">
        <add name="AspNetSqlMembershipProvider"
             applicationName="MyApp" />

<roleManager defaultProvider="AspNetSqlRoleProvider"
        <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="MyAppCS" applicationName="MyApp" />
Note: remember to change the 'connectionStringName' to the appropriate name. Most of the attributes are optional. 
I have mentioned them here so people can change them to their preferred values easier. Specifying 'applicatioName' attribute is strongly recommended. 

BlogEngine web.config:

Repeat the exact same steps for BlogEngine.Net web.config. Just change the connectionStringName to "BlogEngine" or whatever name you have defined in your connectionstring section of 
blogengine's web.config.
Jan 17, 2011 at 12:22 PM
Edited Jan 17, 2011 at 12:25 PM

Recommendations for problem 3:

Well I guess we have two options:

1- Design a masterpage explicitly for the blog which looks the same as your site's masterpage. This approach has some cons. e.g. you have to rewrite you master page's code in your blog. making maintenance harder.

Or maybe you have some custom controls in your master page which are not accessible in your blog.

2- Add a class library which contains the masterpage(s) + controls that are shared between your blog and site. I've got the idea from Dave Burke's excellent Sueetie CMS. For example let's call this class library SiteCore.

you have to define a masterpage like: 

public class SiteMasterPage : System.Web.UI.MasterPage


Then add a reference to this project from BE. And change site.master.cs to inherit from it:

public partial class StandardSite : SiteCore.SiteMasterPage


Add another reference to this library fro your root and you can access this master page in your site as well.

Also, Add any shared control to the class library. For example navigation menu:

public class NavigationMenu: System.Web.UI.UserControl


And handle the html generation of the control from there. Note that you can put control in a separate class library for better separation if you're going to build a more complex solution.