How do you construct HtmlResponseMessage?



How do you construct HtmlResponseMessage?..

Answer / 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

More ASP.NET Interview Questions

What is session and application variable in asp net?

0 Answers  


What is asp.net ajax?

0 Answers  


Difference between datagrid and datareader?

1 Answers  


How do cookies work? Give an example of their abuse.

0 Answers  


What data types do the RangeValidator control support?

2 Answers   Siebel Systems,






What is dataset and uses of dataset ?

6 Answers   HCL, TCS,


Is it possible to use two versions of assembly at the same time?If possible explain with code?

3 Answers   Tech Mahindra,


What is a ashx file?

0 Answers  


About Usage of server variables ?

2 Answers   Cognizant, CTS,


How to use DevExpress controls

1 Answers  


How long do session variables last?

0 Answers  


What is manifest in .net framework?

0 Answers  


Categories