Disable URL rewriting for specific URLs

by: Ted Nyberg (Hallvarsson & Halvarsson)

There comes a time when you need to prohibit URL rewriting for specific URLs within your EPiServer CMS website. For example, I've implemented an ashx handler that is used to deliver vCard files on our company's web site.

If I would insert a regular hyperlink to this handler on a page it would link to the current page, not the handler file. Basically, EPiServer doesn't have a way of rewriting this URL.

In order to make EPiServer CMS ignore this specific file or URL when performing URL rewriting we have to add the following to the application's start event:

protected void Application_Start(Object sender, EventArgs e)
{
   FriendlyUrlRewriteProvider.UnTouchedPaths.Add(
"/Modules/vCard.ashx"); }

Now I'm able to successfully link to the ashx handler without URL rewriting interfering.

Note: The FriendlyUrlRewriteProvider class is part of the EPiServer.Web namespace.

17 January 2008


Comments

  1. Nice! Should have been possible to put these "untouchables" in the web.config file. Probably not that hard to write a small HttpModule to read and add these paths during initialization.
  2. Not sure you need an HttpModule; one could simply add a section to web.config and then implement a method that adds each URL string to UntouchedPaths on application start.
  3. The point if the HttpModule was to avoid having to change the site code (which require a recompilation.) :-) This would be a nice module to have on EPiCode - a generic FriendlyUrlExceptions module.
  4. Ah, can't argue there, Steve! :) If I decide to implement it that way I'll make sure to share it!
  5. Episerver 4 had an undocumented web.config key to disable url-rewrite of different extensions. Why this was removed in episerver 5 is a mystery to me. It didn't enable you to remove a specific path though, but normally you would want to disable url-rewrite of all .ashx files.
Post a comment    
User verification Image for user verification  
Ted Nyberg (Hallvarsson & Halvarsson)

About me

I'm a consultant with the corporate communications consultancy Hallvarsson & Halvarsson, part of the transatlantic stakeholder management and financial communications firm Sage Holdings.

My focus areas include web applications, intranets, and corporate websites.

Live Messenger

Hallvarsson & Halvarsson logo
 MCPD, MCTS and MCP logos

Bloggtoppen.se


Syndications


Archive


Tag cloud

EPiTrace logger