This is a follow-up on Return HTML from ASP.NET Web API.
I followed the instructions but I get Error 406 in the browser. My code:
[Produces("text/html")]
[Route("api/[controller]")]
public class AboutController : Controller
{
[HttpGet]
public string Get()
{
return "<html><body>Welcome</body></html>";
}
...
and, simply:
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
}
When I remove the Produces line I get the plain text <html><body>Welcome</body></html> in the browser (no error).
What am I missing? Thanks.