ASP.Net Web Api帮助 [英] ASP.Net Web Api Help

查看:92
本文介绍了ASP.Net Web Api帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我刚刚在ASP.Net中学习网络Apis ...到目前为止,我已经掌握了它,我的迷你项目运行良好。我只是想知道是否有人会向我解释为什么我们必须声明

Hi,
i am just learning web Apis in ASP.Net ... I getting the hang of it so far and my mini projects are working well. I was just wondering if someone would explain to me why we have to declare

[ResponseType(typeof(myTable))] 

高于每个IHttpAction结果?那也是。



谢谢。

above every IHttpAction result? and also what that does.

Thank you.

推荐答案

用它来指定当声明的返回类型是HttpResponseMessage或IHttpActionResult时,由操作返回的实体类型。生成ApiDescription时,ApiExplorer将读取ResponseType。



https://msdn.microsoft.com/en-us/library/system.web.http.description.responsetypeattribute(v = vs.118).aspx [ ^ ]



所以原因是告诉用户(消费者)他们可以期待什么来自你。
Use this to specify the entity type returned by an action when the declared return type is HttpResponseMessage or IHttpActionResult. The ResponseType will be read by ApiExplorer when generating ApiDescription.

https://msdn.microsoft.com/en-us/library/system.web.http.description.responsetypeattribute(v=vs.118).aspx[^]

So the reason is to tell the user(consumer) what they can expect from you.


这篇关于ASP.Net Web Api帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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