HttpStatusCode
https://docs.microsoft.com/en-us/dotnet/api/system.net.httpstatuscode?view=netframework-4.7.2
422 UnprocessableEntity
What HTTP status response code should I use if the request is missing a required parameter?
Status 422 seems most appropiate based on the spec.
The 422 (Unprocessable Entity) status code means the server understands the content type of the request entity (hence a 415(Unsupported Media Type) status code is inappropriate), and the syntax of the request entity is correct (thus a 400 (Bad Request) status code is inappropriate) but was unable to process the contained instructions. For example, this error condition may occur if an XML request body contains well-formed (i.e., syntactically correct), but semantically erroneous, XML instructions.
They state that malformed xml is an example of bad syntax (calling for a 400). A malformed query string seems analogous to this, so 400 doesn't seem appropriate for a well-formed query-string which is missing a param.
UPDATE @DavidV correctly points out that this spec is for WebDAV, not core HTTP. But some popular non-WebDAV APIs are using 422 anyway, for lack of a better status code (see this).
system.net.HttpStatusCode 没有UnprocessableEntity枚举类型,422。
https://github.com/dotnet/corefx/issues/4382
https://github.com/dotnet/core/issues/1335 但是.net core 2.1已经支持了
HttpStatusCode的更多相关文章
- HttpStatusCode 枚举
.NET Framework 类库 HttpStatusCode 枚举 包含为 HTTP 定义的状态代码的值. 命名空间:System.Net程序集:System(在 system.dll 中) ...
- HTTP状态码(HTTPStatusCode)
HTTP状态码(HTTPStatusCode) 祓焘铺 布稍酡 盛坭馆 距熏屿砥 女装出来扔了套到床上然后自己穿了套 跎徨鼻卩 权术埭 悌颞 蔹咽诹ㄒ 椿酣漂作 钱是小事关键是没有老师耸了 ...
- Asp.Net Core通过HttpStatusCode状态处理响应结果
在我的一个Asp.Net Core 2.1 的项目中,我们需要通过获得服务器返回的状态,去实现不用的操作,经过多方资料查询和实践,个人总结一种方法 一.修改控制器 在要返回值的控制器Action中,R ...
- Abp中自定义Exception的HttpStatusCode
Abp中在新版本中,抛出的异常(比如:UserFriendlyException)通过AjaxResponse封装后返回的时候,HttpStatusCode默认指定成了500. 对于一些默认封装好的处 ...
- [asp.net web api] HttpStatusCode的使用
摘要 在开放api的时,我们需要返回不同的状态给调用方,以告诉它们当前请求的结果,是成功了还是失败了.当然这种给调用方的反馈有很多种做法,这里就说是web api内置的对Http状态码.http状态码 ...
- 转帖:HttpStatusCode状态说明C#版
Continue 等效于 HTTP 状态 100.Continue 指示客户端可能继续其请求. SwitchingProtocols 等效于 HTTP 状态 101.SwitchingProtocol ...
- 如何在asp.net mvc3中使用HttpStatusCode
下载了asp.net mvc 4的源码看了看,没怎么看清楚.不过个人觉得MVC4 beta中Web API这个是比较不错的,虽然说它是往传统回归. web api最好的莫过于它更加适合使用jquery ...
- HandleErrorAttribute只能处理httpStatusCode为500的异常(服务器异常)
HandleErrorAttribute源代码: [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited ...
- ASP.NET MVC with Entity Framework and CSS一书翻译系列文章之第二章:利用模型类创建视图、控制器和数据库
在这一章中,我们将直接进入项目,并且为产品和分类添加一些基本的模型类.我们将在Entity Framework的代码优先模式下,利用这些模型类创建一个数据库.我们还将学习如何在代码中创建数据库上下文类 ...
随机推荐
- Mininet加强版——DOT(分布式OpenFlow试验平台)
前言 之前在做SDN实验的时候,需要用到包含2000+个交换机的fattree拓扑,当时用的是mininet,生成整个拓扑需要十五六个小时,最终在异常艰苦的环境下做完了实验,之后听说了有DOT(Dis ...
- mvc中使用uploadify批量上传的应用
网上找了很多资料都没有发现一个好用.可以用的uploadify批量上传的应用,这里通过官方和自己的一些项目需要整理了一个出来. 希望能帮助到需要的人. 效果图:
- Zend Studio 中创建简单的phpfile模板和xhtml类phpfile模板
<!--简单的phpfile模板,带有创建时间和作者--><?php/*** ==============================================* @dat ...
- php 正则表达式四,例子
PHP常用正则表达式汇总:http://bbs.php100.com/read-htm-tid-83266.html 1.非空匹配: .+ 2.浮点数匹配: ^\d+.\d{2}$ 3.手机号匹配: ...
- py, pyc, pyw, pyo, pyd 及发布程序时的选择 Compiled Python File (.pyc)
Python 程序扩展名(py, pyc, pyw, pyo, pyd)及发布程序时的选择 - 司开星的专栏 - CSDN博客 https://blog.csdn.net/chroming/artic ...
- 常用的SQLalchemy 字段类型
https://blog.csdn.net/weixin_41896508/article/details/80772238 常用的SQLAlchemy字段类型 类型名 python中类型 说明 In ...
- 转+总结!! 关于jsp页面取值方式
1. 前台往后台传值,通过提交表单,在后台有set,get方法,可以直接取到.如果通过request.getParameter(paramName) 去获取通过会报空指针异常. 其中requ ...
- 面试常见的selenium问题
1.如何切换iframe 问题:如果你在一个default content中查找一个在iframe中的元素,那肯定是找不到的.反之你在一个iframe中查找另一个iframe元素或default co ...
- python创建一个线程和一个线程池
创建一个线程 1.示例代码 import time import threading def task(arg): time.sleep(2) while True: num = input('> ...
- Django组件 - Django请求生命周期、中间件
一.Django请求生命周期 在学习中间件之前,先了解一下Django的请求生命周期,如下图: 1)client代表浏览器,浏览器内部为我们封装了socket,Django的WSGI模块也封装了soc ...