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

Can we store object in viewstate?

0 Answers  


What are the different web pages?

0 Answers  


Can you nest updatepanel within each other?

0 Answers  


Contrast the use of an abstract base class against an interface?

5 Answers   iLink,


What is the use of placeholder control?

0 Answers  


What is asp net objects?

0 Answers  


What are main return types supported in Web API?

0 Answers  


Explain how cookies work. Give an example of cookie abuse.

0 Answers  


why we should use more than one web.config files in our application? I have two web.config files in my application. One in the root directory and another one inside a sub folder. When the application runs which web.config file will run? why?

1 Answers  


can I use session variable in App_code Class page??

3 Answers   Wipro,


How many types of sessions are there in asp net?

0 Answers  


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

1 Answers   FT,


Categories