2

In my asp.net core 2.0 application, I need to show the details of a payment receipt as a view to the user. I also need to send to user the same html text as an email (minus the top navigation bar).

My thought was to put the payment details in a partial view. I can then use this partial view on the website as well as in the email.

In appears Html object is injected into razor pages automatically such that one can, for example, call @Html.Partial(). Is there a way to use this Html object from the Controller class? Or, is there a different mechanism to render .cshtml file into html string? Regards.

Peter
  • 11,260
  • 14
  • 78
  • 155

1 Answers1

0

You might try Microsoft.AspNetCore.Html.HtmlString or Microsoft.AspNetCore.Html.HtmlFormattableString. You can return these directly from the controller.

GlennSills
  • 3,977
  • 26
  • 28