Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

Any way to disable UrlRewriteProvider and also the FriendlyHtmlRewriteToExternal part for a specific path?

Vote:
 

We have a standard aspx page that is not an EPiServer template, just a simple aspx page and this page contains a jquery template among other things. 

The problem is that EpiServer tries to UrlRewrite the href attribute on "a" tags and src attribute on "img" tags. In our case we have something like <img src="${thumbnailUrl}" /> on /somepath/sometemplate.tmpl.aspx but it gets rewritten when requested to be <img src="/somepath/${thumbnailUrl}" />.

I have tried added UrlRewiteProvider.AddExcludedPath("/somepath/") to global.asax in the Application_Start event, but EPiServer still rewrites the url. The only way and can get EPiServer to not touch my file is to remove the urlrewriting part from web.config and that is a no go. I can also hook up on HtmlRewriteToExternal.HtmlRewriteInit and later on FriendlyHtmlRewriteToExternal.HtmlRewritingUrl and see that EPiServer actually tries to rewrite it even though i have told EPiServer to keeps it hands away from "somepath".

Why is EPiServer ignoring my UrlRewiteProvider.AddExcludedPath? And how can I tell it to keeps it hands of anything in my specified path?

#70515
Apr 22, 2013 15:00
Vote:
 

After much decompiling it was apparently a bug inside UrlRewriteModule that didn't check for ExcludedPaths and still added a HtmlRewrite response filter regardless of the current page was being excluded or not. 

Workaround inside Application_Start in global.asax:

//workaround for EPiServer not checking for excluded paths when html rewriting
UrlRewriteModuleBase.HttpRewriteInit += (o, args) =>
{
  UrlRewriteModuleBase urm = o as UrlRewriteModuleBase;
  if (urm != null)
  {
    urm.HtmlAddingRewriteToExternalFilter += (sender1, eventArgs) =>
    {
      eventArgs.Cancel = UrlRewriteProvider.IsExcludedPath(eventArgs.Url.Path);
    };
  }
};

#70561
Apr 23, 2013 12:24
Vote:
 

Another option is to set 

UrlRewriteProvider.Module.FURLRewriteResponse = false;

somewhere on the request (e.g. in Page_Load in your aspx file). Then that request will not be parsed for url rewrites.

#70595
Apr 23, 2013 17:17
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.