How do you construct HtmlResponseMessage?

Answer Posted / nirav desai

Following is the way to construct to do so,

public class TestController : ApiController
{
public HttpResponseMessage Get()
{
HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, "value");
response.Content = new StringContent("Testing", Encoding.Unicode);
response.Headers.CacheControl = new CacheControlHeaderValue()
{
MaxAge = TimeSpan.FromMinutes(20)
};
return response;
}
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does ascx stand for?

506


Explain how asp.net page works?

541


What is a 401 redirect?

507


What is page fragment caching?

553


Which is an advantage of application service providers?

489






What is .net remoting?

567


What is a user session?

499


What is the difference between ASP Session State and ASP.Net Session State?

578


What is use of Master Page in ASP.NET web pages?

621


What are validator? Name the validation controls in asp.net?

500


What is asp.net master page?

557


What is difference between web api and web services?

533


What are directives in asp.net? List down all the important directives.

498


List of words of preprocessor in .net?

514


Explain the purpose of storyboard.targetproperty.

519