Lots of people have this query on how to integrating BlogEngine to an existing site. Here is the solution that explains how to integrate blogengine.net into existing site.

– Copy BlogEngine code to a subfolder of your existing site, say it Blogs.

– Make the following changes from you BlogEngine web.config file into your application web.config file,

1 – Find and copy the following code from your BlogEngine web.config file and paste it in your Web Application web.config file under “configSections” tag,

<sectionGroup name="BlogEngine">
 <section name="blogProvider" requirePermission="false" type="BlogEngine.Core.Providers.BlogProviderSection, BlogEngine.Core" allowDefinition="MachineToApplication" restartOnExternalChanges="true" />
</sectionGroup>

2 – Find and copy the following code from your BlogEngine web.config file and paste it in your web application web.config file just after “configSections” tag,

<BlogEngine>
 <blogProvider defaultProvider="DbBlogProvider">
 <providers>
 <add name="XmlBlogProvider" type="BlogEngine.Core.Providers.XmlBlogProvider, BlogEngine.Core"/>
 <add name="DbBlogProvider" type="BlogEngine.Core.Providers.DbBlogProvider, BlogEngine.Core" connectionStringName="BlogEngine"/>
 </providers>
 </blogProvider>
</BlogEngine>

3 – Add the connection string if you have not already have one.

4 – If you don’t already have connection string in your existing web application web.config file, find and copy the following code in your BlogEngine web.config file, and paste it after the “BlogEngine” tag from the above step,

<connectionStrings>
 <clear/>
 <add name="LocalSqlServer" connectionString="dummy"/>
 <!-- Mono complains if LocalSqlServer isn't specified -->
 <add name="BlogEngine" connectionString="Data Source=192.168.0.59;User ID=sa;Password=magnet;persist security info=False;initial catalog=new_BlogEngine;" providerName="System.Data.SqlClient"/>
</connectionStrings>

5 – Find and copy everything within “appSettings” tag from BlogEngine web.config, and paste it within “appSettings” tag in your web application web.config file,

<appSettings>
 <add key="BlogEngine.FileExtension" value=".aspx"/>
 <!-- You can e.g. use "~/blog/" if BlogEngine.NET is not located in the root of the application -->
 <add key="BlogEngine.VirtualPath" value="~/blogs/"/>
 <!-- The regex used to identify mobile devices so a different theme can be shown -->
 <add key="BlogEngine.MobileDevices" value="(nokia|sonyericsson|blackberry|samsung|sec\-|windows ce|motorola|mot\-|up.b|midp\-)"/>
 <!-- The name of the role with administrator permissions -->
 <add key="BlogEngine.AdminRole" value="Administrators"/>
 <!--This value is to provide an alterantive location for storing data.-->
 <add key="StorageLocation" value="~/Blogs/App_Data/"/>
 <!--A comma separated list of script names to hard minify. It's case-sensitive. -->
 <add key="BlogEngine.HardMinify" value="blog.js,widget.js,WebResource.axd"/>
</appSettings>

NOTE: I have copy pasted “appSettings” tag for your reference, you should not include “appSettings” tag and copy everything within it.

NOTE: I have changed the value of “BlogEngine.VirtualPath” to refer to our sub directory rather than the top level directory.

6 – Find and copy everything within “assemblies” tag from your BlogEngine web.config file, and paste it within “assemblies” tag of your web application web.config file.

NOTE: Paste only those tags within “assemblies” tag which do not already exists.

<compilation>
<assemblies>
 <add assembly="System.Management, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
 <add assembly="System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
 <add assembly="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
 <add assembly="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
 <add assembly="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
 <add assembly="System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
 <add assembly="System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>

NOTE: I have copy pasted “assemblies” tag for your reference, you should not include “assemblies” tag and copy everything within it.

7 – Find and copy the following line from BlogEngine web.config, and paste it in your web application web.config file just under “compilation” tag from above point,

NOTE: Paste this code in your web application web.config file only if already does not exists.

<globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="auto" uiCulture="auto"/>

8 – Find and copy the following line from BlogEngine web.config, and paste it in your web application web.config file just under “globalization” tag from above point,

NOTE: Paste this code in your web application web.config file only if already does not exists.

<httpRuntime enableVersionHeader="false" useFullyQualifiedRedirectUrl="true" maxRequestLength="16384" executionTimeout="3600" requestLengthDiskThreshold="16384"/>

9 – Find and copy the following line from BlogEngine web.config, and paste it in your web application web.config file just under “httpRuntime” tag from above point,

NOTE: Paste this code in your web application web.config file only if already does not exists.

<machineKey validationKey="D9F7287EFDE8DF4CAFF79011D5308643D8F62AE10CDF30DAB640B7399BF6C57B0269D60A23FBCCC736FC2487ED695512BA95044DE4C58DC02C2BA0C4A266454C" decryptionKey="BDAAF7E00B69BA47B37EEAC328929A06A6647D4C89FED3A7D5C52B12B23680F4" validation="SHA1" decryption="AES"/>

10 – Change the authentication mode in your web application web.config file to “Forms” and find and copy the following line from BlogEngine web.config, and paste it in your web application web.config within “authentication” tag,

NOTE: if you want to use your own form for authentication then change the value of the “loginUrl” attribute of the “form” tag to the login page from your site.

<authentication mode="Forms">
 <forms timeout="129600" name=".AUXBLOGENGINE" protection="All" slidingExpiration="true" loginUrl="~/login.aspx" cookieless="UseCookies"/>
 </authentication>

NOTE: I have copy pasted “authentication” tag for your reference, this tag will already be there in your web application web.config file, so just check the “mode” of authentication and the “loginUrl” value of the form tag.

11 – Find and copy the following line from BlogEngine web.config, and paste it in your web application web.config file

<pages enableSessionState="false" enableViewStateMac="true" enableEventValidation="true">
 <controls>
 <add namespace="Controls" tagPrefix="blog"/>
 </controls>
</pages>

NOTE: Paste this code in your web application web.config file only if already does not exists. If it already exists just copy everything within “controls” tag from you BlogEngine web.config file and paste in within “controls” tag of your web application web.config file.

NOTE: I have copy pasted “pages” and “controls” tags for your reference, you should not include “pages” and “controls” tag if they already exists and copy everything within it. If they don’t exists then copy the entire “page” tag.

12 – Change the custom error mode in your web application web.config file if you want to redirect user to “error page”.

NOTE: if you want to use your own error page change the value of the “mode” attribute of the “customErrors” tag and the value of “redirect” attribute of the “error” tag within it, as per your requirements,

<customErrors mode="RemoteOnly" defaultRedirect="~/error404.aspx">
 <error statusCode="404" redirect="~/error404.aspx"/>
</customErrors>

13 – Find and copy the following line from BlogEngine web.config, and paste it in your web application web.config file just after “customErrors” tag from above point,

NOTE: Paste this code in your web application web.config file only if already does not exists.

<membership defaultProvider="DbMembershipProvider">
 <providers>
 <clear/>
 <add name="XmlMembershipProvider" type="BlogEngine.Core.Providers.XmlMembershipProvider, BlogEngine.Core" description="XML membership provider" passwordFormat="Hashed"/>
 <add name="SqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="BlogEngine" applicationName="BlogEngine"/>
 <add name="DbMembershipProvider" type="BlogEngine.Core.Providers.DbMembershipProvider, BlogEngine.Core" passwordFormat="Hashed" connectionStringName="BlogEngine"/>
 </providers>
</membership>
<roleManager defaultProvider="DbRoleProvider" enabled="true" cacheRolesInCookie="true" cookieName=".BLOGENGINEROLES">
 <providers>
 <clear/>
 <add name="XmlRoleProvider" type="BlogEngine.Core.Providers.XmlRoleProvider, BlogEngine.Core" description="XML role provider"/>
 <add name="SqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="BlogEngine" applicationName="BlogEngine"/>
 <add name="DbRoleProvider" type="BlogEngine.Core.Providers.DbRoleProvider, BlogEngine.Core" connectionStringName="BlogEngine"/>
 </providers>
</roleManager>

NOTE: if these tags already exists just copy paste the content within “providers” tag and paste it within respective tag.

14 – Find and copy the following line from BlogEngine web.config, and paste it in your web application web.config file just after “roleManager” tag from above point,

NOTE: Paste this code in your web application web.config file only if it does not exists.

<siteMap defaultProvider="PageSiteMap" enabled="true">
 <providers>
 <add name="PageSiteMap" description="The site map provider that reads in the .sitemap XML files." type="BlogEngine.Core.Web.Controls.PageSiteMap, BlogEngine.Core"/>
 <add name="SecuritySiteMap" description="Used for authenticated users." type="System.Web.XmlSiteMapProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" securityTrimmingEnabled="true" siteMapFile="Web.sitemap"/>
 </providers>
</siteMap>

NOTE: if these “siteMap” tag already exists just copy paste the content within “providers” tag and paste it within your web application “provider” tag within “siteMap” tag.

15 – Find the “httpModules” tag within “system.web” tag in BlogEngine web.config and copy the content within “httpModules” tag, and paste it in “httpModules” tag within “system.web” tag within your Web Application web.config

<httpModules>
 <add name="WwwSubDomainModule" type="BlogEngine.Core.Web.HttpModules.WwwSubDomainModule, BlogEngine.Core"/>
 <add name="UrlRewrite" type="BlogEngine.Core.Web.HttpModules.UrlRewrite, BlogEngine.Core"/>
 <add name="CompressionModule" type="BlogEngine.Core.Web.HttpModules.CompressionModule, BlogEngine.Core"/>
 <add name="ReferrerModule" type="BlogEngine.Core.Web.HttpModules.ReferrerModule, BlogEngine.Core"/>
 <!--Remove the default ASP.NET modules we don't need-->
 <remove name="PassportAuthentication"/>
 <remove name="Profile"/>
 <remove name="AnonymousIdentification"/>
</httpModules>

NOTE: If any of the “add” tag already exists in “httpModules” tag in your Web Application web.config, do not copy it again. Make sure you only have one copy of each “add” tag within “httpModules”.

16 – Find the “httpHandlers” tag within “system.web” tag in BlogEngine web.config and copy the content within “httpHandlers” tag, and paste it in “httpHandlers” tag within “system.web” tag within your Web Application web.config

<httpHandlers>
 <add verb="*" path="file.axd" type="BlogEngine.Core.Web.HttpHandlers.FileHandler, BlogEngine.Core" validate="false"/>
 <add verb="*" path="image.axd" type="BlogEngine.Core.Web.HttpHandlers.ImageHandler, BlogEngine.Core" validate="false"/>
 <add verb="*" path="syndication.axd" type="BlogEngine.Core.Web.HttpHandlers.SyndicationHandler, BlogEngine.Core" validate="false"/>
 <add verb="*" path="sitemap.axd" type="BlogEngine.Core.Web.HttpHandlers.SiteMap, BlogEngine.Core" validate="false"/>
 <add verb="*" path="trackback.axd" type="BlogEngine.Core.Web.HttpHandlers.TrackbackHandler, BlogEngine.Core" validate="false"/>
 <add verb="*" path="pingback.axd" type="BlogEngine.Core.Web.HttpHandlers.PingbackHandler, BlogEngine.Core" validate="false"/>
 <add verb="*" path="opensearch.axd" type="BlogEngine.Core.Web.HttpHandlers.OpenSearchHandler, BlogEngine.Core" validate="false"/>
 <add verb="*" path="metaweblog.axd" type="BlogEngine.Core.API.MetaWeblog.MetaWeblogHandler, BlogEngine.Core" validate="false"/>
 <add verb="*" path="rsd.axd" type="BlogEngine.Core.Web.HttpHandlers.RsdHandler, BlogEngine.Core" validate="false"/>
 <add verb="*" path="css.axd" type="BlogEngine.Core.Web.HttpHandlers.CssHandler, BlogEngine.Core" validate="false"/>
 <add verb="*" path="js.axd" type="BlogEngine.Core.Web.HttpHandlers.JavaScriptHandler, BlogEngine.Core" validate="false"/>
 <add verb="*" path="rating.axd" type="BlogEngine.Core.Web.HttpHandlers.RatingHandler, BlogEngine.Core" validate="false"/>
 <add verb="*" path="opml.axd" type="BlogEngine.Core.Web.HttpHandlers.OpmlHandler, BlogEngine.Core" validate="false"/>
 <add verb="*" path="blogml.axd" type="BlogEngine.Core.Web.HttpHandlers.BlogMLExportHandler, BlogEngine.Core" validate="false"/>
 <add verb="*" path="sioc.axd" type="BlogEngine.Core.Web.HttpHandlers.Sioc, BlogEngine.Core" validate="false"/>
 <add verb="*" path="apml.axd" type="BlogEngine.Core.Web.HttpHandlers.Apml, BlogEngine.Core" validate="false"/>
 <add verb="*" path="foaf*.axd" type="BlogEngine.Core.Web.HttpHandlers.Foaf, BlogEngine.Core" validate="false"/>
</httpHandlers>

NOTE: If any of the “add” tag already exists in “httpHandlers” tag in your Web Application web.config, do not copy it again. Make sure you only have one copy of each “add” tag within “httpHandlers”.

17 – Find the “modules” tag within “system.webServer” tag in BlogEngine web.config and copy the content within “modules” tag, and paste it in “modules” tag within “system.webServer” tag within your Web Application web.config

<modules>
 <add name="WwwSubDomainModule" type="BlogEngine.Core.Web.HttpModules.WwwSubDomainModule, BlogEngine.Core"/>
 <add name="UrlRewrite" type="BlogEngine.Core.Web.HttpModules.UrlRewrite, BlogEngine.Core"/>
 <add name="CompressionModule" type="BlogEngine.Core.Web.HttpModules.CompressionModule, BlogEngine.Core"/>
 <add name="ReferrerModule" type="BlogEngine.Core.Web.HttpModules.ReferrerModule, BlogEngine.Core"/>
</modules>

NOTE: If any of the “add” tag already exists in “modules” tag in your Web Application web.config, do not copy it again. Make sure you only have one copy of each “add” tag within “modules”.

18 – Find the “handlers” tag within “system.webServer” tag in BlogEngine web.config and copy the content within “handlers” tag, and paste it in “handlers” tag within “system.webServer” tag within your Web Application web.config

<handlers accessPolicy="Read, Write, Script, Execute">
 <add name="FileHandler" verb="*" path="file.axd" type="BlogEngine.Core.Web.HttpHandlers.FileHandler, BlogEngine.Core" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode"/>
 <add name="ImageHandler" verb="*" path="image.axd" type="BlogEngine.Core.Web.HttpHandlers.ImageHandler, BlogEngine.Core" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode"/>
 <add name="Syndication" verb="*" path="syndication.axd" type="BlogEngine.Core.Web.HttpHandlers.SyndicationHandler, BlogEngine.Core" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode"/>
 <add name="Sitemap" verb="*" path="sitemap.axd" type="BlogEngine.Core.Web.HttpHandlers.SiteMap, BlogEngine.Core" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode"/>
 <add name="Trackback" verb="*" path="trackback.axd" type="BlogEngine.Core.Web.HttpHandlers.TrackbackHandler, BlogEngine.Core" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode"/>
 <add name="Pingback" verb="*" path="pingback.axd" type="BlogEngine.Core.Web.HttpHandlers.PingbackHandler, BlogEngine.Core" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode"/>
 <add name="OpenSearch" verb="*" path="opensearch.axd" type="BlogEngine.Core.Web.HttpHandlers.OpenSearchHandler, BlogEngine.Core" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode"/>
 <add name="MetaWeblog" verb="*" path="metaweblog.axd" type="BlogEngine.Core.API.MetaWeblog.MetaWeblogHandler, BlogEngine.Core" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode"/>
 <add name="RSD" verb="*" path="rsd.axd" type="BlogEngine.Core.Web.HttpHandlers.RsdHandler, BlogEngine.Core" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode"/>
 <add name="CssHandler" verb="*" path="css.axd" type="BlogEngine.Core.Web.HttpHandlers.CssHandler, BlogEngine.Core" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode"/>
 <add name="Javascript" path="js.axd" verb="*" type="BlogEngine.Core.Web.HttpHandlers.JavaScriptHandler, BlogEngine.Core" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode"/>
 <add name="Rating" verb="*" path="rating.axd" type="BlogEngine.Core.Web.HttpHandlers.RatingHandler, BlogEngine.Core" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode"/>
 <add name="Opml" verb="*" path="opml.axd" type="BlogEngine.Core.Web.HttpHandlers.OpmlHandler, BlogEngine.Core" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode"/>
 <add name="BlogML" verb="*" path="blogml.axd" type="BlogEngine.Core.Web.HttpHandlers.BlogMLExportHandler, BlogEngine.Core" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode"/>
 <add name="SIOC" verb="*" path="sioc.axd" type="BlogEngine.Core.Web.HttpHandlers.Sioc, BlogEngine.Core" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode"/>
 <add name="Apml" verb="*" path="apml.axd" type="BlogEngine.Core.Web.HttpHandlers.Apml, BlogEngine.Core" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode"/>
 <add name="Foaf" verb="*" path="foaf*.axd" type="BlogEngine.Core.Web.HttpHandlers.Foaf, BlogEngine.Core" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode"/>
</handlers>

NOTE: If any of the “add” tag already exists in “handlers” tag in your Web Application web.config, do not copy it again. Make sure you only have one copy of each “add” tag within “handlers”.

19 – Move directories from BlogEngine.Web/App_Code under your Web Application/App_code

20 – Move directories from BlogEngine.Web/App_GlobalResources under your Web Application/App_GlobalResources.

21 – Add reference to BlogEngine.Core.Dll in your application.

Please drop me a comment if you have any doubts or you liked this post.

Hope this helps 🙂