`

return HttpResponseMessage with ObjectContent Json Type

 
阅读更多
public async Task<HttpResponseMessage> 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<object>(new
                {
                    return1="A",
                    return2="B"
                }, Configuration.Formatters.JsonFormatter)
            };
        }
} 

 

分享到:
评论

相关推荐

    Laravel开发-jsonresponse

    例如,`return redirect()-&gt;route('home')-&gt;with(['message' =&gt; 'Success'])-&gt;json();`。 8. **错误处理**: 在API开发中,Laravel提供了`response()-&gt;errorJson()`方法,用于快速创建包含错误信息的JSON响应。 ...

    怎样实现Ajax 跨域访问

    res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type'); ``` #### 四、利用iframe通信 使用iframe进行跨域通信通常涉及到两种方式:一种是利用iframe的`src`属性加载数据;另一种则是...

    python3.6.5参考手册 chm

    The json module: JavaScript Object Notation The plistlib module: A Property-List Parser ctypes Enhancements Improved SSL Support Deprecations and Removals Build and C API Changes Port-Specific ...

    python实现微信小程序用户登录、模板推送

    headers = {'Content-Type': 'application/json'} payload = { "touser": openid, "template_id": template_id, "data": data } response = requests.post(url, headers=headers, json=payload) return ...

    ExtAspNet_v2.3.2_dll

    ExtAspNet - ExtJS based ASP.NET Controls with Full AJAX Support ExtAspNet是一组专业的Asp.net控件库,拥有原生的AJAX支持和丰富的UI效果, 目标是创建没有ViewState,没有JavaScript,没有CSS,没有...

Global site tag (gtag.js) - Google Analytics