Home > Database > Mysql Tutorial > .net Web API 2,return HttpResponseMessage with ObjectContent

.net Web API 2,return HttpResponseMessage with ObjectContent

WBOY
Release: 2016-06-07 15:44:28
Original
1490 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

public async 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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template