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的更多相关文章

  1. HttpStatusCode 枚举

    .NET Framework 类库 HttpStatusCode 枚举 包含为 HTTP 定义的状态代码的值. 命名空间:System.Net程序集:System(在 system.dll 中)   ...

  2. HTTP状态码(HTTPStatusCode)

    HTTP状态码(HTTPStatusCode) 祓焘铺 布稍酡 盛坭馆 距熏屿砥 女装出来扔了套到床上然后自己穿了套 跎徨鼻卩 权术埭 悌颞 蔹咽诹ㄒ 椿酣漂作 钱是小事关键是没有老师耸了 ...

  3. Asp.Net Core通过HttpStatusCode状态处理响应结果

    在我的一个Asp.Net Core 2.1 的项目中,我们需要通过获得服务器返回的状态,去实现不用的操作,经过多方资料查询和实践,个人总结一种方法 一.修改控制器 在要返回值的控制器Action中,R ...

  4. Abp中自定义Exception的HttpStatusCode

    Abp中在新版本中,抛出的异常(比如:UserFriendlyException)通过AjaxResponse封装后返回的时候,HttpStatusCode默认指定成了500. 对于一些默认封装好的处 ...

  5. [asp.net web api] HttpStatusCode的使用

    摘要 在开放api的时,我们需要返回不同的状态给调用方,以告诉它们当前请求的结果,是成功了还是失败了.当然这种给调用方的反馈有很多种做法,这里就说是web api内置的对Http状态码.http状态码 ...

  6. 转帖:HttpStatusCode状态说明C#版

    Continue 等效于 HTTP 状态 100.Continue 指示客户端可能继续其请求. SwitchingProtocols 等效于 HTTP 状态 101.SwitchingProtocol ...

  7. 如何在asp.net mvc3中使用HttpStatusCode

    下载了asp.net mvc 4的源码看了看,没怎么看清楚.不过个人觉得MVC4 beta中Web API这个是比较不错的,虽然说它是往传统回归. web api最好的莫过于它更加适合使用jquery ...

  8. HandleErrorAttribute只能处理httpStatusCode为500的异常(服务器异常)

    HandleErrorAttribute源代码: [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited ...

  9. ASP.NET MVC with Entity Framework and CSS一书翻译系列文章之第二章:利用模型类创建视图、控制器和数据库

    在这一章中,我们将直接进入项目,并且为产品和分类添加一些基本的模型类.我们将在Entity Framework的代码优先模式下,利用这些模型类创建一个数据库.我们还将学习如何在代码中创建数据库上下文类 ...

随机推荐

  1. 66、多种多样的App主界面Tab(1)------ ViewPager实现Tab

    <?xml version="1.0" encoding="utf-8"?> <!-- bottom.xml --> <Linea ...

  2. 【BZOJ4384】[POI2015]Trzy wieże 树状数组

    [BZOJ4384][POI2015]Trzy wieże Description 给定一个长度为n的仅包含'B'.'C'.'S'三种字符的字符串,请找到最长的一段连续子串,使得这一段要么只有一种字符 ...

  3. 【BZOJ1822】[JSOI2010]Frozen Nova 冷冻波 几何+二分+网络流

    [BZOJ1822][JSOI2010]Frozen Nova 冷冻波 Description WJJ喜欢“魔兽争霸”这个游戏.在游戏中,巫妖是一种强大的英雄,它的技能Frozen Nova每次可以杀 ...

  4. [hihoCoder] 拓扑排序·一

    The hints of the problem has given detailed information to implement the topological sorting algorit ...

  5. angualar入门学习-- 作用域$scope

    作用域$scope: 是ng执行环境,视图与controller之间的胶水,双向绑定的基础 $scope提供里$watch方法,监听数据模型变化 $scope提供里$apply方法,将数据模型变化更新 ...

  6. 160628、利用Oracle rownum让表排序字段值连续

    利用Oracle rownum让表排序字段值连续 1.需求说明 表(eval_index)中有字段如下: 表字段 描述 说明 ID 主键 GROUP_ID 分组编号 SORT_NUM 排序序号 按照分 ...

  7. POJ 3037 Skiing(Dijkstra)

    Skiing Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4668   Accepted: 1242   Special ...

  8. matplotlib图像中文乱码(python3.6)

    方法一:(在代码中添加如下代码) import matplotlib #指定默认字体 matplotlib.rcParams['font.sans-serif'] = ['SimHei'] matpl ...

  9. ubuntu 安装低版本firefox

    firefox 57以后很多插件不支持了,ubuntu16自带火狐版本59,想换回56. 1.下载想换回的版本 https://ftp.mozilla.org/pub/mozilla.org/fire ...

  10. 模块化之SeaJS(二)

    Seajs 此文来自 予舍驿站 提供简单.极致的模块化开发体验 非官方文档,整理来自己官方文档的文字与实例,方便速查. seajs.configObject aliasObject 别名配置,配置之后 ...