Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Return HTML from ASP.NET 6 API

$
0
0

I am expecting "Hello World" as output the way it provides in Web API 2.
Instead it gives following output:

{"Version":{"Major":1,"Minor":1,"Build":-1,"Revision":-1,"MajorRevision":-1,"MinorRevision":-1},"Content":{"Headers":[{"Key":"Content-Type","Value":["text/html"]}]},"StatusCode":200,"ReasonPhrase":"OK","Headers":[],"RequestMessage":null,"IsSuccessStatusCode":true}
[HttpGet] 
public HttpResponseMessage Get()
{
var response = new HttpResponseMessage {
Content = new StringContent("<html><body>Hello World</body></html>")
};
response.Content.Headers.ContentType = new MediaTypeHeaderValue("text/html"); return response;
}

Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>