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 the use of service provider?

0 Answers  


Which class provides methods that can be used to manage role membership to be used in user authorization?

3 Answers   Wipro,


What is redirecting behavior?

0 Answers  


What is the asp.net mvc folder conventions? : asp.net mvc

0 Answers  


What are the advantages of Web API?

0 Answers  


what are the State management and Its Uses

2 Answers  


What is role manager work in web.config? how to restrict perticular pages from the users using the role manager?

1 Answers   Patni,


Why mvc is better than asp.net? : Asp.Net MVC

0 Answers  


How to kill session?

18 Answers   Protech,


What is the Difference between MVC And MVP design pattrens

0 Answers   Symphony,


When working with ASP.Net server controls, it is important to use the right event handlers to capture the event for the application to function properly. What event would you use to capture the selection of a new item in a DropDownList control? a) The Click event. b) The SelectionChanged event. c) The SelectionIndexChanged event. d) The ChangedSelection event.

4 Answers   Syntax Softtech,


Whats the difference between abstract factory pattern and factory pattern?

0 Answers  


Categories