Copied to clipboard

Flag this post as spam?

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


  • Gustavo Castelo 14 posts 34 karma points
    Oct 05, 2012 @ 12:51
    Gustavo Castelo
    0

    umbraco 4.9: Why html is always rendered as encoded html

    Hi guys,

    I'm using 4.9 for the first time and noticed that razor is encoding all the html in the macro even a simple:

     <p>Test</p> 

    is outputed as:

    <p>Test</p> 

    I've also tried:

    @{ <p>Test</p> }

    With the same results.

    The macro is included as usual in the template ( even forced the language attribute to make sure..):

    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">  
       <p>sdasda</p>
       <umbraco:Macro Alias="News" runat="server" language="razor"></umbraco:Macro>
    </asp:Content>

    Notice that the  <p>sdasda</p> is outputed normaly, not encoded:

    This didn't happend in 4.7 (the last version I used). Has anything changed? What am I doing wrong?

    Thanks for your help!

  • Richard Terris 273 posts 715 karma points
    Oct 05, 2012 @ 15:36
    Richard Terris
    0

    Have you tried

    <p> @Test </p>

    ?

  • Gustavo Castelo 14 posts 34 karma points
    Oct 05, 2012 @ 17:02
    Gustavo Castelo
    0

    That won't work as Test is not a variable/property.

    The problem I'm having is that instead of outputing just: Test, as you would expect it's doing &lt;p&gtp;Test&lt;/p&gt; 

     

  • Richard Terris 273 posts 715 karma points
    Oct 05, 2012 @ 17:05
    Richard Terris
    0

    Sorry I must have picked you up wrong.

    Maybe flag it is an issue?

  • Gustavo Castelo 14 posts 34 karma points
    Oct 05, 2012 @ 17:20
    Gustavo Castelo
    0

    This should have been easily noticed by the team. I think I just have something wrong in my configuration... I hope.

  • Dan Diplo 1554 posts 6205 karma points MVP 6x c-trib
    Oct 05, 2012 @ 17:22
    Dan Diplo
    0

    This doesn't happen to me with a fresh Umbraco 4.9 install, so it must be something peculiar to you.

  • Gustavo Castelo 14 posts 34 karma points
    Oct 05, 2012 @ 17:23
    Gustavo Castelo
    0

    Yes.. I am using uSiteBuilder and thought it might have something to do with the macro being in a uSiteBuilder template but tried with a clean template created in the backend an have the same issue..

  • Dan Diplo 1554 posts 6205 karma points MVP 6x c-trib
    Oct 05, 2012 @ 17:27
    Dan Diplo
    0

    I'm not aware of any config setting for this, but perhaps if you could performa  diff of web.config and /config/umbracoSettings.config between your site and a clean download?

  • Gustavo Castelo 14 posts 34 karma points
    Oct 05, 2012 @ 18:14
    Gustavo Castelo
    0

    Just did that and the files look the same apart from specific entries related to my website.

    And, indeed, the clean version outputs the macro normally... I'm off to a good start.. :)

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Oct 07, 2012 @ 15:55
  • Richard Terris 273 posts 715 karma points
    Oct 08, 2012 @ 13:20
    Richard Terris
    0

    One of the reasons I use uSiteBuilder is to AVOID using Macros'

  • Gustavo Castelo 14 posts 34 karma points
    Oct 08, 2012 @ 14:02
    Gustavo Castelo
    0

    @Jeroen Breuer, that might work but the issue is that normally you don't need to do that. You just write the html and you're done.. 

    @Richard Terris, cool but I do like to use Macros and razor and have succefully mix it in another project with usitebuilder but that's using 4.7.1..

    Haven't got a change to look at it this weekend but I'll let you know if I find something.

     

    Thanks for your input guys!

  • Richard Terris 273 posts 715 karma points
    Oct 08, 2012 @ 14:05
    Richard Terris
    0

    To my knowledge you don't need to encode HTML unless you have requirements to do so.

    <p>Hello</p> should be rendered as Hello in the browser.

    Have you tried various browsers? If it's the same in all then I'd suggest It's either a problem with your setup or that version of Umbraco.

    You could try this in another project?

  • Gustavo Castelo 14 posts 34 karma points
    Oct 08, 2012 @ 14:07
    Gustavo Castelo
    0

    Yes, like I said in a previous post. Have tried in a clean solution and works as expected. I'll dig into it this afternoon if I have some spare time.

  • Richard Terris 273 posts 715 karma points
    Oct 08, 2012 @ 14:21
    Richard Terris
    0

    Please let us know - I'm quite curious about this

  • Gustavo Castelo 14 posts 34 karma points
    Oct 08, 2012 @ 23:43
    Gustavo Castelo
    0

    Well finally got it and it was my fault. It seems I was using a wrong version of the System.Web.WebPages.

    Umbraco 4.9 comes with one along with other MVC dlls, which I referenced in the project BUT forgot to set the Copy Local to true for this dll and some others.

    So the first time I used Razor I got the System.Web.Webpages not found error, so due to old habit I went to the project and open the Add Deployed Dependencies dialog and selected the ones for MVC. I've been doing that since 4.6 to have local copies of the MVC dlls before commiting to SVN.

    But it seems that these dlls, which I'm pretty sure are for MVC 3, has some conflict with the macro rendering in 4.9 and outputs the html encoded. 

    After some trial and error I found that I had the System.Web.Webpages that comes from umbraco was not being copied to the bin folder and once I did that the output returned back to normal.

    I'm still curious to why the output was encoded with the MVC3 dlls but for now, problem solved.

Please Sign in or register to post replies

Write your reply to:

Draft