首頁 >資料庫 >mysql教程 >.net Web API 2,return HttpResponseMessage with ObjectContent

.net Web API 2,return HttpResponseMessage with ObjectContent

WBOY
WBOY原創
2016-06-07 15:44:281480瀏覽

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)
            };
        }


陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn