.Text Tip: Non-Mapped Folders

One of the things that I've wanted for a long time with .Text is the ability to have folders that are not mapped to the .Text blogging engine. Well, I had a great idea while I was in the shower this morning (all great ideas come while bathing, at least in my experience), and it proved to work famously. Create your directory, create a new web.config file, and add the following information only:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

<system.web>

 <httpHandlers>

     <clear />
            <add verb="*" path="trace.axd" type="System.Web.Handlers.TraceHandler" />
            <add verb="*" path="*.aspx" type="System.Web.UI.PageHandlerFactory" />
            <add verb="*" path="*.ashx" type="System.Web.UI.SimpleHandlerFactory" />
            <add verb="*" path="*.asmx" type="System.Web.Services.Protocols.WebServiceHandlerFactory, System.Web.Services, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" validate="false"/>
            <add verb="*" path="*.rem" type="System.Runtime.Remoting.Channels.Http.HttpRemotingHandlerFactory, System.Runtime.Remoting, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" validate="false"/>
            <add verb="*" path="*.soap" type="System.Runtime.Remoting.Channels.Http.HttpRemotingHandlerFactory, System.Runtime.Remoting, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" validate="false"/>
            <add verb="*" path="*.asax" type="System.Web.HttpForbiddenHandler" />
            <add verb="*" path="*.ascx" type="System.Web.HttpForbiddenHandler" />
            <add verb="GET,HEAD" path="*.dll.config" type="System.Web.StaticFileHandler" />
            <add verb="GET,HEAD" path="*.exe.config" type="System.Web.StaticFileHandler" />
            <add verb="*" path="*.config" type="System.Web.HttpForbiddenHandler" />
            <add verb="*" path="*.cs" type="System.Web.HttpForbiddenHandler" />
            <add verb="*" path="*.csproj" type="System.Web.HttpForbiddenHandler" />
            <add verb="*" path="*.vb" type="System.Web.HttpForbiddenHandler" />
            <add verb="*" path="*.vbproj" type="System.Web.HttpForbiddenHandler" />
            <add verb="*" path="*.webinfo" type="System.Web.HttpForbiddenHandler" />
            <add verb="*" path="*.asp" type="System.Web.HttpForbiddenHandler" />
            <add verb="*" path="*.licx" type="System.Web.HttpForbiddenHandler" />
            <add verb="*" path="*.resx" type="System.Web.HttpForbiddenHandler" />
            <add verb="*" path="*.resources" type="System.Web.HttpForbiddenHandler" />
            <add verb="GET,HEAD" path="*" type="System.Web.StaticFileHandler" />
            <add verb="*" path="*" type="System.Web.HttpMethodNotAllowedHandler" />
 </httpHandlers> 

 <httpModules>
     <clear />
            <add name="OutputCache" type="System.Web.Caching.OutputCacheModule" />
            <add name="Session" type="System.Web.SessionState.SessionStateModule" />
            <add name="WindowsAuthentication" type="System.Web.Security.WindowsAuthenticationModule" />
            <add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule" />
            <add name="PassportAuthentication" type="System.Web.Security.PassportAuthenticationModule" />
            <add name="UrlAuthorization" type="System.Web.Security.UrlAuthorizationModule" />
            <add name="FileAuthorization" type="System.Web.Security.FileAuthorizationModule" />
            <add name="ErrorHandlerModule" type="System.Web.Mobile.ErrorHandlerModule, System.Web.Mobile, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
 </httpModules>

 </system.web>
</configuration>

Basically, what this does is remap all of the extensions as described in the machine.config file for that directory only. The only problem with this method is, it will not process your IIS default documents, so if you were to say “http://blogs.yourblogsite.com/test”, you would receive a “Resource cannot be found” error, but if you said “http://blogs.yourblogsite.com/test/default.aspx” it would process normally.

There you have it, I hope someone finds this useful. I'll be implementing it over at LonghornBlogs.com momentarily.

No Comments