Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Paul Blair 466 posts 731 karma points
    Apr 13, 2010 @ 06:21
    Paul Blair
    0

    Problem with RenderTemplate?

    I have trying to render a page using RenderTemplate:

    string body = umbraco.library.RenderTemplate(1193);

    But the code returns an error with:

    A potentially dangerous Request.Form value was detected from the client

    I am using v4.0.3

    Any ideas

    Thanks

    Paul

  • Paul Blair 466 posts 731 karma points
    Apr 13, 2010 @ 22:28
    Paul Blair
    0

    the problem appears when the function is called in the AfterPublish event (even if the page ID is for a different page than the one being published).

    It works fine otherwise.

  • Nick Collings 6 posts 26 karma points
    Apr 16, 2010 @ 14:06
    Nick Collings
    0

    Hi Paul,

    I am having the same problem, after reading this post, and its causing a lot of problems as this functionality is crucial to a project I'm working on right now. Have you found anything to help sort this? I have tried putting <pages validateRequest="false"> in the web.config but that doesn't help.

    I have found a plugin from Darren Ferguson which performs the html rendering correctly but it operates on the whole site. I need it to be limited to certain doctypes.

    Does anyone on the Umbraco forum know of a work around for the RenderTemplate issue me and Paul have found? If not is there another means of outputting a node (of a certain doctype) to html on the server?

    Thanks, Nick

  • Paul Blair 466 posts 731 karma points
    Apr 17, 2010 @ 11:19
    Paul Blair
    0

    Hi Nick,

    No, I never found a solution. I changed the funcitonality of my site slightly so I could avoid the AfterPublish event - not ideal but fortunate it didn't bother my client too much.

    Cheers

    Paul

  • Jeff Grine 149 posts 189 karma points
    May 13, 2010 @ 22:28
    Jeff Grine
    0

    You can get around that error by adding this in the template:

    <umbraco:DisableRequestValidation runat="server"/>

     

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    May 13, 2010 @ 22:31
    Sebastiaan Janssen
    0

    Or you could use this code in your user control:

            protected void Page_Init(object sender, EventArgs e)
            {
                ((umbraco.UmbracoDefault)Page).ValidateRequest = false;
    
            }
  • Jeff Grine 149 posts 189 karma points
    May 14, 2010 @ 16:23
    Jeff Grine
    0

    Actually, I'm trying to use this now and running into another problem. I need to render the page being published, but the first time it is published I still get the dangerous request error. After it is published once, it works fine. Any ideas why disabling request validation only works after the page has been published once? Any workarounds?

    Thanks, Jeff

  • Mikael Mørup 297 posts 326 karma points
    May 20, 2010 @ 10:26
    Mikael Mørup
    0

    I think rendertemplate works with the nodefactory, and hence only with published content.

  • Marthijn 6 posts 26 karma points
    May 20, 2010 @ 15:24
  • Jeff Grine 149 posts 189 karma points
    May 20, 2010 @ 15:41
    Jeff Grine
    0

    Mikael is right, it works with nodefactory, so can only run after umbraco.config has been written out. This hasn't happened yet when the after publish event is running. I wound up moving the code (back) to a usercontrol datatype where I can check that the document has been published once before allowing a button click to do the rendering I needed.

Please Sign in or register to post replies

Write your reply to:

Draft