1

I'd want to save HTML that's being generated by

return View("view name", ComplexModel); in Controller's method with IActionResult return type

Is it possible to extract that html without obtaining it from user side by e.g JavaScript?

Something like:

string html = View("view name", ComplexModel).RawHtml;

Joelty
  • 1,751
  • 5
  • 22
  • 64
  • 1
    Possible duplicate of [How to render an ASP.NET MVC view as a string?](https://stackoverflow.com/questions/483091/how-to-render-an-asp-net-mvc-view-as-a-string) – A Friend Jan 21 '19 at 15:19
  • Possible duplicate of [Get html from MVC 4 view into a string](https://stackoverflow.com/questions/18442343/get-html-from-mvc-4-view-into-a-string) – Brank Victoria Jan 21 '19 at 15:23
  • @AFriend @BrankVictoria are you sure it applies to .net core? ``'Engines' does not exist in the namespace 'Microsoft.AspNetCore.Mvc.ViewEngines' `` – Joelty Jan 21 '19 at 15:26
  • [This answer](https://stackoverflow.com/a/31906578/6144259) seems to address core 2 directly – A Friend Jan 21 '19 at 15:34

0 Answers0