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

Explain about consistent programming model in the .NET framework?

0 Answers  


Difference Between ReadOnly and Constant Variable in compile time and Run Time.

3 Answers   Phoenix Technologies, Quadrant,


Which is faster viewbag or viewdata?

0 Answers  


A web service can only be written in .net? State whether true or false.

0 Answers  


What are the types of assemblies and where can u store them and how a private assembly is used only by a single application, and is stored in that application's install directory (or a subdirectory therein)?

3 Answers   Accenture,






Explain what a diffgram is, and a good use for one?

1 Answers  


Define viewstate in .net?

0 Answers  


What is razor? : asp.net mvc

0 Answers  


How to reduce the width of textbox in editcommandcolumn of datagrid?

0 Answers  


Define what is razor? : asp.net mvc

0 Answers  


What ports must be open for DCOM over a firewall? What is the purpose of Port 135?

0 Answers  


calling result set one procedure to anothar procedure in sql2000

0 Answers  


Categories