Custom RenderControl vs Friendly URLs

Vote:
 

Hi,

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
                ctrl.RenderControl(htw);
            }
           
            var pageSource = [some replacing here] 
           

            writer.Write(pageSource);
        }

    

I also tried Emil's solution from http://www.meadow.se/wordpress/retreive-html-code-for-a-web-user-control/, but problem occurs even if I run it Page_Unload.

 

Any ideas how to make my urls pretty?

 

thanks!

Bartek

#84757
Apr 07, 2014 12:38
Vote:
 

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?

#84774
Apr 07, 2014 14:23
Vote:
 

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

#84873
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.