如何在web api中使用消息返回状态代码 [英] how to return status code with message in web api

查看:109
本文介绍了如何在web api中使用消息返回状态代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



i希望像这样返回



401未授权,

404未找到,

500内部服务器错误

200成功

201成功创建

Hi All,

i want to return like this

401 unauthorize,
404 not found,
500 internal server error
200 successful
201 successfull creted

推荐答案

你需要使用 IHttpActionResult

参考: Web API中的操作结果 [ ^ ]



-KR
You need to use IHttpActionResult for this.
Refer this: Action Results in Web API[^]

-KR


这篇关于如何在web api中使用消息返回状态代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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