soundaranbu / Razor.Templating.Core

Razor Templating Engine to render Razor Views(.cshtml files) to String in Console, Web, Service, Desktop workloads in .NET Core 3+

Home Page:https://soundaranbu.medium.com/render-razor-view-cshtml-to-string-in-net-core-7d125f32c79

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Read stuff from viewbag after rendering

mattiasnordqvist opened this issue · comments

It should be possible to read data from the the viewbag after rendering, so that a template like this can output the subject and from values.

@model RazorTemplates.Letter
@{
    ViewData["Subject"] = "Very good subject";
    ViewData["From"] = "support@hello.com";
}
<!doctype html>
<html>
<head>

...

Hey @mattiasnordqvist, thanks for raising this. I'm not sure how possible is this. But still I can have a look & let you know if this possible or not.

Thanks

Hey @mattiasnordqvist, the razor renderer doesn't provide these back to the caller other than the rendered string. Hence, it's not possible to implement this. I'm closing the issue. Thanks for your suggestion.