this is another post, i will show you how to return html content in asp.net mvc core
private IHostingEnvironment _env;
public HomeController(IHostingEnvironment env)
{
_env = env;
}
[HttpGet]
public ActionResult GetHtmlFileData()
{
var result = System.IO.File.ReadAllText(System.IO.Path.Combine(_env.WebRootPath + @"\Docs", "welcomepage.html"));
return new ContentResult
{
Content = result,
StatusCode = (int)HttpStatusCode.OK,
ContentType = "text/html"
};
}
or :
[HttpGet]
public ActionResult GetAsHtmlData()
{
//you can also use as parameter
var tempvariable = "ajay@gmail.com";
//multiple line of html code when it contains double code replace single code (CTRL + H)
var result = $@"<html><body><div><a href='mailto: { tempvariable}
'>{tempvariable}</a></div></body></html>";
return new ContentResult
{
Content = result,
StatusCode = (int)HttpStatusCode.OK
ContentType = "text/html"
};
}
0 Comments
if you have any doubts , please let me know