Return HTML from ASP.NET Web API ASP.NET Core 2 and get http status 406

As KTCO pointed out here :

Starting with AspNetCore 2.0, it's recommended to use ContentResult instead of the Produce attribute

The solution is:

[HttpGet]
public ContentResult Get()
{
    return new ContentResult {
        ContentType = "text/html",
        StatusCode = (int) HttpStatusCode.OK,
        Content = "<html><body>Welcome</body></html>"
    };
}

There is no need to change AddMvc (and there is no Produce attribute, of course).

I hope this helps someone.