Integrate with existing app?

Topics: ASP.NET 2.0
Mar 24, 2009 at 2:54 PM
Simple question: Can BlogEngine.NET be integrated within my existing site, (i.e. serving only as my sites blogging engine, while my existing functionality remains untouched), or must it be installed as it's own solution?

Thanks.
Coordinator
Mar 24, 2009 at 11:31 PM
There's 3 basic possibilities.

1. You install BE into it's own subfolder off of your main site and mark that subfolder an an application in IIS.  In this case, BE is running as its own application.  Probably no changes need to be made to your existing site.

2. You install BE into the same root folder as your existing site.  In this case, BE and your main site are a single application in IIS.  Depending on what you have in your existing site, some changes to either your existing site or BE may need to be made so they can co-exist.  But you wouldn't need to lose any functionality in your existing website.

3. You install BE into a subfolder off of your main site (like option # 1), but the subfolder is NOT a separate application in IIS (like option # 2).  The subfolder can be named "blog" for example.  You will probably need to make some small changes to your existing site depending on how it's setup.  The web.config file between your existing site and BE would probably need to be combined.  But generally speaking, there should be less changes needed to your existing site for this scenario compared to option # 2.  In this case, you would tell BE that it is installed in a subfolder off the root of the application by changing the "BlogEngine.VirtualPath" key in the web.config file like so:

<add key="BlogEngine.VirtualPath" value="~/blog/"/>
Apr 13, 2009 at 1:58 PM
This is a great reply -- thanks. I'm glad this sort of thing can be done with blogengine.net.

For option #2, can you point me to any specific documentation on how to do it? A forum post or a wiki would be very helpful.

Thanks!
Apr 13, 2009 at 5:59 PM
I had this same question and it seems to me that option 1 is missing a useful feature: I want my BE sub-web to know that is it rooted by a main site and have a system concept of "root home page". It could be a sibling variable to the VirtualPath variable that lets me define how to get back to the root website that the BE site is extending. Then, the main title bar would have links to both the BE home and the root home. As it is now, I have to manually add a link back to my root system to which ever style I select for my blog. I would think that this is a very typical use of BE and that it should be included in the base.

I would also expect that it would not necessarily be a direct url rooting. I could have my BE for www.mysite.com at www.mysite.com/blog or blog.mysite.com or even www.someotherplace.com/blog.

What do you think?
Coordinator
Apr 13, 2009 at 7:29 PM
@RickW, this is something you may already be aware of, but if you're mainly looking to have a link back to the main website, I would just add a standard <a> hyperlink tag in my theme's site.master file.

<a href="/">Main Site</a>
... or ...
<a href="http://blog.mysite.com/">Main Site</a>

A variable for the main site could be added to BE like you suggested, but my (unresearched) guess would be that most people (more than 50%) aren't in this situation and wouldn't need this extra link on their blog.  So for these people, then would end up needing to delete the link.  Without the link, the people who need the link always have the option to manually add it.

You could create a post for this in the Issue Tracker, and if people want it, it can start collecting votes.
Coordinator
Apr 13, 2009 at 7:45 PM
@Rocky1138, there may be some documentation on this, but none that I can remember seeing (sorry).  I think the steps required for # 2 can vary largely enough depending on what you have in your existing site, that a single piece of documentation might be difficult to create.

I'll list here some of the considerations that come to mind for combining BE with an existing website (option # 2).

1. The web.config file for BE and your existing site need to be combined.  The web.config file for BE has a relatively large number of settings in it.  So unless your existing site's web.config file also has a lot of settings in it, I would copy your existing web.config file settings into the BE web.config file.

2. BE uses default.aspx as its homepage.  Default.aspx is hard-coded in a few places within BE.  Additionally, BE has some links that point to the homepage without default.aspx in them.  So, in some cases, the homepage link is http://www.example.com/default.aspx and sometimes it's http://www.example.com/.  Depending on your needs, you may need to let BE's homepage be your site's homepage.  You could modify BE's homepage so it includes some elements from your existing website's homepage.  BE's homepage is the default.aspx file.  Although, the same default.aspx is also used when in some other cases too, like when viewing blog entries by category, date, or tag.  So you may need to set it up so some of your existing homepage elements are displayed in default.aspx only when the homepage is being displayed.

3. You would want to look out for files in BE and in your existing website that have the same filename and decide which one to use, or possibly combine them.

Other than that, I think just copying the BE files and folders into your existing website and seeing what happens is the next thing to do.  Definitely have a backup of files beforehand in case something doesn't go right.
Apr 21, 2009 at 2:37 PM
Ok, I am an old man of 52 and I am confused by your installation instructions. 

I have admin access to our test web server and downloaded the web project version on to the test server. 

I unzipped the folder to my desktop and now have a folder entitled "BlogEngine[1].NET 1.5(web).  Inside that folder is another folder called "BlogEngine.Web". 

Here is where I am confused.  Do I copy the entire BlogEngine.Web folder into the root folder of my web site (our test server hosts several sites in separate folders by business division)?  Or do I open the BlogEngine.Web folder and just copy the contents inside to my apps.publicdomainname.com web site folder?

Right now our main site blocks access to the blog videos or I would have already downloaded them and followed the installation instructions on them.  I've requested access to your blog sites from our Help Desk, but that is a slow train comin'.

Thanks.
Coordinator
Apr 21, 2009 at 6:38 PM
Hi Randy.  If you want the blog to exist as a sub-folder underneath the apps.publicdomainname.com site, then you can copy the entire BlogEngine.Web folder into the apps.publicdomainname.com web site folder.  You could then rename the BlogEngine.Web folder to just 'blog'.  The URL to the blog would be apps.publicdomainname.com/blog.

If you then marked the 'blog' folder as a web application in IIS (aka Application Starting Point), then there will be very little or no extra configuration work you would need to do to get BE working within the apps.publicdomainname.com site.  Marking the 'blog' folder as an application in IIS is what I described as option # 1 back on March 24th.
Coordinator
Apr 24, 2009 at 5:09 AM
Edited Apr 24, 2009 at 5:11 AM
mercsd: If the blog folder is marked as an application in IIS, then you shouldn't need to (and also can't) move the web.config file into the root folder.  When a folder is marked as an app in IIS, that sub-folder is its own application and that sub-folder is considered the root of the blog.  Also, when the folder is marked as an application in IIS, the BlogEngine.VirtualPath you'll want to use will be ~/.

Here's a small tutorial showing the steps to mark a folder as an application in IIS (IIS7 is towards the bottom, and is only 1 step).

If you're getting garbage characters, there's two things you can do to get more user-friendly error messages.

1. In the web.config file, there's a <customErrors> tag that looks like something similar to:

<customErrors mode="RemoteOnly" defaultRedirect="~/error404.aspx">

Changing that to the following will help show errors for some cases:

<customErrors mode="Off">

2. In the global.asax file in the root of the blog, add the following code right after the <script RunAt="server"> tag,

void Application_Error(object sender, EventArgs e)
{
    HttpContext context = ((HttpApplication)sender).Context;
    if (context.Error != null)
    {
        Exception ex = context.Error;
        string msg = string.Empty;
        
        while (ex != null)
        {
            if (!string.IsNullOrEmpty(ex.Message))
                msg += ex.ToString() + "<br /><br />";
            ex = ex.InnerException;
        }
        context.Response.Clear();
        context.Response.Write(msg);
        context.Response.End();
    }        
}


This change is more likely to eliminate the garbage characters so you can see a real error message.  The formatting of the error message isn't particularly great with this code, but is definitely a good start.
Apr 28, 2009 at 10:10 PM
Hello again,

We got the blog working on our corporate site anc my colleague has taken over tweaking its appearance.

This post is personal.  I am trying to get the blog working on my own site as an application.  I followed the installation videos and tried to open up the blog but I got an error message related to the theme of my web site.

<title>Configuration Error</title> <style> body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px} b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px} H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon } pre {font-family:"Lucida Console";font-size: .9em} .marker {font-weight: bold; color: black;text-decoration: none;} .version {color: gray;} .error {margin-bottom: 10px;} .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; } </style>

Server Error in '/blog' Application.

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Theme 'inseason' cannot be found in the application or global theme directories.

Source Error:

Line 50:         </customErrors>
Line 51:        
Line 52: 		<pages theme="inseason">
Line 53: 			<controls>
Line 54: 				<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>


In the Web.config for my site I have a theme set and the blog application, of course, knows nothing about this theme.  I am assuming that I will have to combine the Web.config files as you recommended above, but my question is, do I need to copy the main theme from my site into the themes folder of the blog app or do I need to create a theme in my blog app per your documentation instructions that matches my main theme?

Thanks,

Randy
Apr 28, 2009 at 10:25 PM
Ok, I got rid of the <pages theme=""> directive in my site's Web.config file and the blog compiled and opened up.  I guess I need to create a theme for the blog that incorporates some of the style of my main site.  At least I got it running now, this is going to be fun!
Oct 27, 2009 at 11:27 AM

Ok!

I changed the custom errors to off and now I know what the error is.

Can anyone help me?

http://www.mindbiz.com.br/blog/ - JUST TRY IT!

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. 

Parser Error Message: Could not load file or assembly 'MySql.Data, Version=5.2.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The system cannot find the file specified.

Source Error: 

Line 50:     <compilation debug="false">
Line 51:       <assemblies>
Line 52:         <add assembly="MySql.Data, Version=5.2.5.0, Culture=neutral, PublicKeyToken=C5687FC88969C44D"/>
Line 53:         <add assembly="System.Management, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
Line 54:         <add assembly="System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>


Source File: D:\Domains\mindbiz.com.br\wwwroot\blog\web.config    Line: 52 

 

THANX ANYWAY!

Coordinator
Oct 27, 2009 at 11:38 PM

I'm guessing you don't have the following line in your BE web.config file, right?

<add assembly="MySql.Data, Version=5.2.5.0, Culture=neutral, PublicKeyToken=C5687FC88969C44D"/>

The standard BE web.config file doesn't have that.

The root of your website must have a web.config file in it with that line (the parent folder of your BLOG directory).

If you're not using MySql in the parent application, you can just remove that line from the parent web.config file.  If you are using MySql in the parent application, you can modify the parent application's web.config file to prevent settings from that config file from propagating down to the blog application.  To do this, edit the parent application's web.config file and wrap the existing <system.web> section in a <location> tag as shown below:

<location path="." inheritInChildApplications="false">
      <system.web>

      ......... lots of stuff .........

     </system.web>
</location>

Again, it's the root folder's web.config file you want to make this change in.

Oct 28, 2009 at 3:19 AM

Sorry, but that is incorrect. That line is there. And for some reason is saying that cannot find the file specified.

 

Just enter the URL and you will see.

Coordinator
Oct 28, 2009 at 7:03 AM

I understand the line is there -- I clicked on the link.

The line should NOT be there.  The default web.config file that comes with BE does not have that line.  That line is trying to load a MySql DLL.  No MySql DLL comes with BE.

The line should be deleted, or if the line is coming from the web.config file in the root folder and is needed for some other application on the website, then follow my instructions above.

Oct 28, 2009 at 11:39 AM

ok...

That worked! but now I am getting another error!

Oct 28, 2009 at 12:23 PM

Fuck Mysql!

I got tired of trying and changed to SQL Server 2008.

 

Done!

 

Thanx for all the help!

Nov 11, 2009 at 8:01 AM

Hi everybody,

how I can read data from class RecentPost in my code and on that way get name of the posts on my page ?

Or is beter way to read xml files from folder Blogs\App_Data\posts\...   ?

Thanks for help