Request.CreateResponse VS中的ASP.NET Web API返回波苏斯 [英] Request.CreateResponse vs returning POCOs in ASP.NET Web API

查看:321
本文介绍了Request.CreateResponse VS中的ASP.NET Web API返回波苏斯的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到了很多样本​​的网络对于使用 Request.CreateResponse 来产生反应的ASP.NET Web API上。如果您在Visual Studio中的一个新的Web API项目时,默认API控制器返回的IEnumerable<串> 字符串。是什么在用法区别​​?

I see a lot of samples on the web for ASP.NET Web API that use Request.CreateResponse to generate responses. If you create a new Web API project in Visual Studio, the default API controllers return IEnumerable<string> or string. What's the difference in usage?

推荐答案

返回一个的Htt presponseMessage 允许您直接控制返回的HTTP响应的各个不同方面。如果返回POCO你有希望,框架你想要做什么。也许会,也许不会。

Returning a HttpResponseMessage allows you to control all different aspects of the returned HTTP response directly. If you return a POCO you have to hope that the framework does what you want. And maybe it will, and maybe it won't.

这篇关于Request.CreateResponse VS中的ASP.NET Web API返回波苏斯的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆