Try our conversational search powered by Generative AI!

Custom RenderControl vs Friendly URLs



I'm using custom Render method for ContentPlaceholders on MasterPage to render html as json safe string. What I noticed is all urls are not parsed by Friendly URLs and are looking like "/Templates/Pages/Hub.aspx?id=13".  

here is piece of code:

protected void RenderJsonSafeContentPlaceHolder(HtmlTextWriter writer, Control Container)
            // setup a TextWriter to capture the markup
            TextWriter tw = new StringWriter();
            var htw = new XhtmlTextWriter(tw, HtmlTextWriter.DefaultTabString);

            foreach (Control ctrl in Container.Controls)
                // render the markup into our surrogate TextWriter
            var pageSource = [some replacing here] 



I also tried Emil's solution from, but problem occurs even if I run it Page_Unload.


Any ideas how to make my urls pretty?




Apr 07, 2014 12:38

Looks like UrlRewriteModule is skipping html which is previously parsed with HttpUtility.HtmlEncode (it's part of [some replacing here]). Probably because it's not a valid html anymore. Anybody knows how to force UrlRewriteModule to parse encoded html?

Apr 07, 2014 14:23

The HTML rewriting is only done on responses of type 'text/html'. And in CMS7.5 HTML rewriting is only done on pages inheriting TemplatePage. 

Depending on which version you are running you could call manually call UrlResolver.GetUrl/GetVirtualPath or Global.UrlRewriteProvider.ConvertToExternal

Apr 08, 2014 15:04
* 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.