Using Blogengine in a subdirectory

Topics: Business Logic Layer
Sep 21, 2007 at 4:03 AM
I seem to have trouble with <httpModules> in Applications that are in subdirectories of my site. When I configured BlogEngine as an Application in a subdirectory, it complained about any <httpModules> that I use in the root Application folder (from by Bin directory) that were not in the Bin directory of BlogEngine. I know I can <clear /> the <httpModules> and then add them back, but there are some that get added in the server wide machine.config that I might want to work in the BlogEngine application.

To avoid this issue, I configured BlogEngine to run in a subdirectory of my basic CMS application:

1. I added a new setting to the BlogSettings of "ServingLocation" which I made default to "~/BlogEngine/".
2. Where I could, instead of using hardcoded paths like "~/posts" I replaced it with something like BlogSettings.ServingLocation + "posts".
3. Where I could not use the BlogSettings (because the reference has to be hardcoded), I updated "~/" with "~/BlogEngine/".
4. Updated the compression module to only compress files in the BlogSettings.ServingLocation directory (the compression was breaking some of my ASP.NET AJAX pages).
5. Moved all the web site files into a BlogEngine subdirectory. I did not move the "App_*" or "Bin" directories.

I think that's about all the changes I made, and BlogEngine does not have to run as a separate application, but instead can live in my site as a subdirectory.

I think it all seems to work. If anyone notices that it does not then please let me know.

http://www.balcoding.com/BlogEngine/
Oct 2, 2007 at 9:00 PM
If you go to the root directories web.config and add <location inheritInChildApplications="false"> (your web.config code)</location> around the areas that you don't want filtering down to your sub directory. Here is an example how I wrap it around everything. Just make sure the open and close tags are somewhere inside your configuration tags.

Top of web.config >

<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<location inheritInChildApplications="false"><!-- tyeodle added -->
<appSettings> etc etc etc

(this area is the rest or your config and then add the following at the bottom of the web.config

</location><!-- tyeodle added -->
</configuration>
Oct 3, 2007 at 3:29 PM
Edited Oct 15, 2007 at 2:53 AM
Never mind, found error. Thanks for assistance.
Oct 3, 2007 at 3:34 PM
Thanks for the tip. It looks like this would be a good way to have Child Applications ignore any HttpModules defined in the root Application that did not need to be used in the Child Application also.

Do you think this method or something similar would be able to keep the same membership and role providers in a Child Application? Would the Child Application share the same security context as the root Application? If I log into the root Application, would I be logged into the Child Application also? What if the membership and role providers depended upon libraries in the root Application "bin" or "App_Code" directories? Would those libraries have to be copied over to the Child Application's folders too?

I'm asking, because I don't want to be required to use a different security context for every application that I install on my site.