How to return html page from WebApi action?
One way to do this is to read the page as a string and then send it in a response of content type "text/html".
Add namespace IO:
using System.IO;
In the controller:
[HttpGet]
[ActionName("Index")]
public HttpResponseMessage Index()
{
var path = "your path to index.html";
var response = new HttpResponseMessage();
response.Content = new StringContent(File.ReadAllText(path));
response.Content.Headers.ContentType = new MediaTypeHeaderValue("text/html");
return response;
}
For ASP.NET Core (not ASP.NET Standard) then if it's a static html file (which it looks like), use the static resource options:
Static files in ASP.NET Core