Copied to clipboard

Flag this post as spam?

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


  • Chris Mahoney 242 posts 454 karma points
    Apr 01, 2019 @ 00:46
    Chris Mahoney
    0

    Get RTE HTML from Partial View Macro

    I'm having trouble with something that sounds like it should be simple (in fact, I'm sure I've done it before!)

    My Document Type has a Rich Text Editor and I simply want to grab the HTML. In my Partial View Macro I have the following:

    string html = Umbraco.Field("bodyText").Value();
    

    That looks simple enough, but it just hangs the site when it's executed. I've left it for a couple of minutes but I can't say whether it eventually times out.

    What am I doing wrong?

    I'm running Umbraco 7.13.2 on a Win 2016 server.

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    Apr 01, 2019 @ 19:38
    Alex Skrypnyk
    0

    Hi Chris

    Try this code:

    var text = Umbraco.AssignedContentItem.GetPropertyValue<string>("bodyText");
    

    What do you have as an output? Can you check the log, maybe there are some exception messages.

    Thanks,

    Alex

  • Chris Mahoney 242 posts 454 karma points
    Apr 01, 2019 @ 20:00
    Chris Mahoney
    0

    No luck, I'm afraid. If I don't include <string> then the line succeeds, but the moment I add either <string> or .ToString() it freezes.

    Task Manager shows the IIS Worker Process using 100% CPU, and if I leave it long enough then eventually the App Pool stops itself and I get an HTTP 503. There doesn't seem to be anything relevant in the log.

    Any ideas?

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    Apr 02, 2019 @ 08:29
    Alex Skrypnyk
    0

    Hi Chris

    I don't think that "GetPropertyValue" can cause performance issues. Can you show the code of the macro or all the page? Did you check the log what issues are there?

    Try to add ?umbdebug=true to query string and you will see MiniProfiler little popup at the right top corner of the site. Maybe MiniProfiler will show what is the issue?

    Thanks,

    Alex

  • Chris Mahoney 242 posts 454 karma points
    Apr 02, 2019 @ 20:25
    Chris Mahoney
    0

    The macro is only the one line; I've commented everything else out so the call to GetPropertyValue is the only thing I'm doing.

    It seems that nothing's going right though, because I can't manage to get MiniProfiler to show up. I've set debug=true and trace=true in Web.config but adding ?umbdebug=true doesn't accomplish anything. I've also tried manually adding @MiniProfiler.RenderIncludes() but that doesn't make anything show up either.

    But... don't worry about it. I've taken another look at what I'm trying to accomplish and have figured out a different way of doing it :)

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    Apr 02, 2019 @ 22:07
    Alex Skrypnyk
    0

    Chris, have some sleep and get back to this issue :) We want to fix it.

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    Apr 09, 2019 @ 16:38
    Alex Skrypnyk
    0

    Hi Chris

    Did you solve the problem? Can you share with the community?

    Alex

  • Chris Mahoney 242 posts 454 karma points
    Apr 09, 2019 @ 20:21
    Chris Mahoney
    1

    Sorry, I've been so busy that I'd forgotten all about this post.

    I realised that I didn't actually need a macro since it would only ever be called from one template. So in the template I'm now using Umbraco.Field("bodyText").ToString() and that works correctly, without freezing.

    I therefore didn't fix the underlying problem, but managed to work around it.

  • Chris Evans 137 posts 353 karma points c-trib
    Apr 02, 2019 @ 02:56
    Chris Evans
    0

    Rich text usually outputs an IHtmlString, so perhaps this would work?

    var text = Umbraco.AssignedContentItem.GetPropertyValue<IHtmlString>("bodyText");
    
Please Sign in or register to post replies

Write your reply to:

Draft