Copied to clipboard

Flag this post as spam?

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


  • John Bergman 483 posts 1132 karma points
    Dec 04, 2023 @ 23:15
    John Bergman
    0

    Pass data through to cshtml rendered by Umbraco.RenderTemplateAsync()

    I have tried with ViewData and VewBag, neither work.

    Is there a way to pass a series of variables (or even a class containing the data) through to the resulting CSHTML executed when RenderTemplateAsync is used?

    (Just to clarify, this is to render email content)

  • Søren Kottal 713 posts 4571 karma points MVP 6x c-trib
    Dec 05, 2023 @ 11:03
    Søren Kottal
    100

    Hi John

    If you can get a HttpContext, you can add them in the Items collection in there, and retrieve them in your view. That is what I used to do in FullTextSearch.

  • John Bergman 483 posts 1132 karma points
    Dec 05, 2023 @ 15:31
    John Bergman
    0

    Thanks.

    I went ahead and created a service object that was scope-based and used Dependency Injection to do it. Seems to be working good; I was hoping that I was just missing something :-)

Please Sign in or register to post replies

Write your reply to:

Draft