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!

What functionality does the HtmlRewritePipe provide?


Can someone explain what the HtmlRewritePipe does, exactly?

I thought it existed to rewrite unfriendly links to friendly links, but I see that the FriendlyUrlRewriteProvider provides that functionality in the ConvertToExternalInternal method.

So...what is the RewritePipe doing?

Jan 08, 2011 0:38

I thoght it found all the links, and reroutet them to the Current UrlRewriter

Jan 08, 2011 17:22

The used UrlRewriteProvider (typically FriendlyUrlRewriteProvider) instance "delivers" instances of HtmlRewriteToExternal (typically instances of FriendlyHtmlRewriteToExternal). The instance of HtmlRewriteToExternal is then responsible to deliver the Stream and RewritePipe instances (the stream instance is then hooked up to httpApplication.Context.Response.Filter) used at parsing the html output. The built in implementation of the Stream (HtmlRewriteStream) uses an instance of HtmlRewritePipe. 

So the RewritePipe instance is responsible for the actual html parsing.

The reason for this design is to make it modular, you can e.g. reuse the built in FriendlyUrlRewriteProvider but replace the actual html parser used. It also makes it possible to hookup to events at different levels, RewritePipe exposes events that are raised for every parsed element/attribute/value in the Html while  the UrlRewriteProvider exposes events on a higher level e.g. when an url is parsed.

Jan 12, 2011 8:38

When I debug the code, what I see is the RewritePipe parsing through every tag, then called FriendlyUrlRewriteProvider to have URLs rewritten.  Is this correct?

Besides allowing the rerwite provider to fix the links, is the RewritePipe used for anything else by EPiServer at the default?  Is there any documentation about how to swap it out for something else?

Jan 13, 2011 23:33

It is correct that the class FriendlyHtmlRewriteToExternal sets up an eventlistner to RewritePipe.HtmlRewriteUrl. In the eventhandler it then delegates the actual Url rewriting to the configured UrlRewriteProvider (that during this raises its url related events).

HtmlRewritePipe is used in PropertyXhtmlString that uses it to parse the property value for dynamic content and permanent links (in CMS6R2 PropertyXhtmlString has been changed so it uses our own parser HtmlStreamReader that resides in EPiServer.Framework). HtmlRewritePipe is also used at export to find links in xHtml properties to be able to keep links intact durign export/import and mirroring.

I don't think there is any documentation regarding swapping parser (I do not know if that is something we "officially" support) and I have not heard about that anybody has done that either.

Jan 14, 2011 13:09
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.