Running a subfolder application under BlogEngine.NET

1. September 2011 20:36 by Johan Skog in ASP.NET, BlogEngen.NET, IIS  //  Tags: , ,   //   Comments (803)

After I finished the installation of BlogEngen.NET and check all the settings and that it did work I did check and see if the application running in a subfolder was still working.

But it wasn't working and that is because the subfolder application inherits all the settings that is done in the parents web.config file.

So I started to Google a solution, because I figured that someone else must have hade the same problem.
But all I did find was about how to install BlogEngen.NET under a subfolder and not the other way around.

And the rest of the information that I did find was to rap parts of the web.config settings with <location path="." inheritInChildApplications="false"></location>

But then parts of the BlogEngen.NET stopped working because I did not have all settings for the subfolders that belong to BlogEngen.NET.

So I figured that if I make a “location“ tag for the subfolder and disable and reset all the settings to default that BlogEngen.NET changes.

And here are the result of that:

<location path="subfolder" allowOverride="true">
    <connectionStrings>
        <remove name="BlogEngine"/>
        <add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>
    </connectionStrings>
    <system.web>
        <compilation debug="false" targetFramework="4.0">
            <assemblies>
                <remove assembly="System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                <remove assembly="System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                <remove assembly="System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                <remove assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                <remove assembly="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                <remove assembly="System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                <remove assembly="System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                <remove assembly="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                <remove assembly="System.Web.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                <remove assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                <remove assembly="System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                <remove assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            </assemblies>
            <expressionBuilders>
                <remove expressionPrefix="LinqLength"/>
                <remove expressionPrefix="Reflect"/>
                <remove expressionPrefix="Session"/>
                <remove expressionPrefix="Server"/>
                <remove expressionPrefix="QueryString"/>
                <remove expressionPrefix="Code"/>
            </expressionBuilders>
        </compilation>
        <membership defaultProvider="AspNetSqlMembershipProvider">
            <providers>
                <clear/>
                <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
            </providers>
        </membership>
        <roleManager defaultProvider="AspNetSqlRoleProvider">
            <providers>
                <clear/>
                <add name="AspNetSqlRoleProvider" connectionStringName="LocalSqlServer" applicationName="/" type="System.Web.Security.SqlRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
                <add name="AspNetWindowsTokenRoleProvider" applicationName="/" type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
            </providers>
        </roleManager>
        <siteMap defaultProvider="AspNetXmlSiteMapProvider">
            <providers>
                <add siteMapFile="web.sitemap" name="AspNetXmlSiteMapProvider" type="System.Web.XmlSiteMapProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
            </providers>
        </siteMap>
        <httpModules>
            <remove name="WwwSubDomainModule"/>
            <remove name="UrlRewrite"/>
            <remove name="CompressionModule"/>
            <remove name="ReferrerModule"/>
            <remove name="SecurityModule"/>
            <remove name="RightModule"/>
        </httpModules>
        <httpHandlers>
            <remove verb="*" path="file.axd"/>
            <remove verb="*" path="image.axd"/>
            <remove verb="*" path="syndication.axd"/>
            <remove verb="*" path="sitemap.axd"/>
            <remove verb="*" path="trackback.axd"/>
            <remove verb="*" path="pingback.axd"/>
            <remove verb="*" path="opensearch.axd"/>
            <remove verb="*" path="metaweblog.axd"/>
            <remove verb="*" path="rsd.axd"/>
            <remove verb="*" path="css.axd"/>
            <remove verb="*" path="js.axd"/>
            <remove verb="*" path="res.axd"/>
            <remove verb="*" path="rating.axd"/>
            <remove verb="*" path="opml.axd"/>
            <remove verb="*" path="blogml.axd"/>
            <remove verb="*" path="sioc.axd"/>
            <remove verb="*" path="apml.axd"/>
            <remove verb="*" path="foaf*.axd"/>
            <remove verb="*" path="*.htm"/>
        </httpHandlers>
    </system.web>
    <system.webServer>
        <modules>
            <remove name="WwwSubDomainModule"/>
            <remove name="UrlRewrite"/>
            <remove name="CompressionModule"/>
            <remove name="ReferrerModule"/>
            <remove name="SecurityModule"/>
            <remove name="RightModule"/>
        </modules>
        <handlers>
            <remove name="FileHandler"/>
            <remove name="ImageHandler"/>
            <remove name="Syndication"/>
            <remove name="Sitemap"/>
            <remove name="Trackback"/>
            <remove name="Pingback"/>
            <remove name="OpenSearch"/>
            <remove name="MetaWeblog"/>
            <remove name="RSD"/>
            <remove name="CssHandler"/>
            <remove name="Javascript"/>
            <remove name="Resource"/>
            <remove name="Rating"/>
            <remove name="Opml"/>
            <remove name="BlogML"/>
            <remove name="SIOC"/>
            <remove name="Apml"/>
            <remove name="Foaf"/>
            <remove name="Html"/>
        </handlers>
    </system.webServer>
</location>

Add it to the end of your web.config file for BlogEngen.NET, just before </configuration>
And change the location path to your subfolder name.
You need to add it for every subfolder you don’t want BlogEngen.NET in.

About Johan

My name is Johan Skog.
I live in Sundsvall, Sweden.
Working as a software developer since 2006 mostly with ASP.Net, SQL, JavaScript and HTML.
But has also worked with classic ASP, PHP, VB6, C / C + +, Pascal

Month List