Hi All,
i want to return html code from web api
i have done
public HttpResponseMessage Get()
{
string Filepath = HttpContext.Current.Request.MapPath(@"~/Template1/Receipt1.html");
string Html = File.ReadAllText(Filepath);
StringBuilder sb = new StringBuilder(Html);
var response = new HttpResponseMessage();
response.Content = new StringContent(sb.ToString());
response.Content.Headers.ContentType = new MediaTypeHeaderValue("text/html");
response.ReasonPhrase = "success";
return response;
}
above is working fine but i want to use IHttpActionResult
public IHttpActionResult Get()
{
string Filepath = HttpContext.Current.Request.MapPath(@"~/Template1/Receipt1.html");
string Html = File.ReadAllText(Filepath);
StringBuilder sb = new StringBuilder(Html);
// what code should i write here
return Ok();
}

Madan ShekarRank #428 · 5.9K reputationPosted Mar 18, 2019, 2:12 AM EDT
Ravi PatelRank #439 · 5.7K reputationPosted Mar 18, 2019, 2:23 AM EDT
Madan ShekarRank #428 · 5.9K reputationPosted Mar 18, 2019, 2:26 AM EDT
Rajeesh MenothRank #118 · 18.4K reputationPosted Mar 19, 2019, 12:00 AM EDT
Puneet KankarRank #446 · 5.6K reputationPosted Mar 18, 2019, 2:34 AM EDT
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts