Are there other ways I can return raw html from controller? As opposed to just using viewbag. like below:
public class HomeController : Controller
{
publ
What was working for me (ASP.NET Core), was to set return type ContentResult, then wrap the HMTL into it and set the ContentType to "text/html; charset=UTF-8". That is important, because, otherwise it will not be interpreted as HTML and the HTML language would be displayed as text.
Here's the example, part of a Controller class:
///
/// Startup message displayed in browser.
///
/// HTML result
[HttpGet]
public ContentResult Get()
{
var result = Content("DEMO Demo started successfully."
+ "
Use Swagger"
+ " to view API.
");
result.ContentType = "text/html; charset=UTF-8";
return result;
}