Thursday, May 05, 2011

Teach Sitecore to ignore a directory


This is a really quick post dedicated to the following scenario. You have either a standalone asp.net web app or legacy website. You want to host it underneath the web root with Sitecore instance configured and have Sitecore completely ignore the whole path (“/webapp”).

The issue you may be having is that during the request, Sitecore would try to “take over” and resolve a dynamic item “webapp” from the content tree which obviously does not exist. So you would get a “document not found” error*:image

*Depending on the version of IIS, you may be experiencing different behavior.

There is a quick way to resolve this. Simply add the path to your standalone website to the “IgnoreUrlPrefixes” list:

   1: <!--  IGNORE URLS
   2:       Set IgnoreUrlPrefixes to a '|' separated list of url prefixes that should not be
   3:       regarded and processed as friendly urls (ie. forms etc.)
   4: -->

5: <setting name="IgnoreUrlPrefixes"
value="/sitecore/default.aspx|/trace.axd|.....|/webapp" />

Now if your are not feeling nerdy today, stop reading and go fix it!

For the ones who continue reading, I can tell that the “ignore url magic” happens within the <httpRequestBegin /> pipeline which is invoked when the request goes through Sitecore.

So before the ItemResolver is hit, the “IgnoreList” processor would read the value of the “IgnoreUrlPrefixes” setting and figure out whether the pipeline needs to be aborted or not:

   1: <httpRequestBegin>
   2:    ...
   3:    <processor type="Sitecore.Pipelines.HttpRequest.IgnoreList, Sitecore.Kernel" />
   4:    <processor type="Sitecore.Pipelines.HttpRequest.SiteResolver, Sitecore.Kernel" />
   5:    ...
   6:    <processor type="Sitecore.Pipelines.HttpRequest.ItemResolver, Sitecore.Kernel" />
   7: </httpRequestBegin>

That’s all folks!

1 comments:

Marian said...

I tried to add value in IgnoreUrlPrefixes but seams that Sitecore ignore the value of this setting. I have problem with Telerik dialog handler. This is my ignoreurlprefixes:
.

I also have all the handlers added in web.config, but I still get the error "Document not found" when I try to open a dialog window on spell checker. If I add a file called "Telerik.Web.UI.DialogHandler.aspx" in sublayout folder the my spell checker run correct. But I have many controls in many directories, so I can't add this file all over the place. Did you had this problem? Thank you. Marian