.net Web API 2,return HttpResponseMessage with ObjectContent

WBOY
Release: 2016-06-07 15:44:28
Original
1405 people have browsed it

public async TaskHttpResponseMessage Register(AllenRegistration model) { 1. Will return 400 Error return Request.CreateResponse( HttpStatusCode.BadReques t); 2. Will return Json Type like {return1:A,returnBL:B} return new HttpResponseMessa

publicasync Task Register(AllenRegistration model)

{

1.


Will return 400 Error

return Request.CreateResponse(HttpStatusCode.BadRequest);


2.

Will return Json Type like {"return1":"A","returnB"L:"B"}

return new HttpResponseMessage(HttpStatusCode.OK)

{
Content = new ObjectContent (new
{
return1="A",

return2="B"
},Configuration.Formatters.JsonFormatter)
};
}

}


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!