MVC ActionResult to use when returning html content

I have some html fragment in memory that I need to do with RenderAction. For example, my action method looks something like this:

var html = "some HTML

How do I render this html using RenderAction, I don’t want to create a view file because it is a dynamic html. And I can not use any of the results of the file, because it does not come from the file. What other ways to do this?

+3
source share
2 answers

Check ContentViewResultor shortcutreturn Content(string html)

+8
source

Immediately I can present two options:

1) You can read this HTML line in the stream and then return it through FileResult (stream, "text/html")

2) HTML <%= Model.MyDynamicHtml %>

1), , .

0

Source: https://habr.com/ru/post/1761323/


All Articles