1.

What is the use of HttpResponseMessage?

Answer»

It is used to set response values such as header and status control. It simply allows us to work with HTTP PROTOCOL. It represents HTTP response messages that encapsulate DATA and status code. 

// GetEmployee action public HttpResponseMessage GetEmployee(INT id) { EMPLOYEE emp = EmployeeContext.Employees.Where(e => e.Id == id).FIRSTORDEFAULT(); if (emp != null) { return Request.CreateResponse<Employee>(HttpStatusCode.OK, emp); } else { return Request.CreateErrorResponse(HttpStatusCode.NotFound, "Employee Not Found"); } }


Discussion

No Comment Found