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已经支持了

304

https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/304

The HTTP 304 Not Modified client redirection response code indicates that there is no need to retransmit the requested resources. It is an implicit redirection to a cached resource. This happens when the request method is safe, like a GET or a HEAD request, or when the request is conditional and uses a If-None-Match or a If-Modified-Since header.

The equivalent 200 OK response would have included the headers Cache-Control, Content-Location, Date, ETag, Expires, and Vary.

转载于:https://www.cnblogs.com/chucklu/p/10302353.html

HttpStatusCode相关推荐

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

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

  2. C#在异常中获取HttpStatusCode用法

    HttpStatusCode用法 catch (WebException e) {string status = null;HttpWebResponse response = (HttpWebRes ...

  3. 利用Node.js为Node.js生成HttpStatusCode辅助类并发布到npm

    作为一个好的Restfull Api不仅在于service url的语义,可读性,幂等,正交,作为http状态码也很重要,一个好的Http Status Code给使用者一个很好的响应,比如200表示 ...

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

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

  5. WebApi2官网学习记录---异常处理

    HttpResponseException 当WebAPI的控制器抛出一个未捕获的异常时,默认情况下,大多数异常被转为status code为500的http response即服务端错误. Http ...

  6. [原]unity3d之http多线程异步资源下载

    郑重声明:转载请注明出处 U_探索 本文诞生于乐元素面试过程,被面试官问到AssetBundle多线程异步下载时,愣了半天,同样也被深深的鄙视一回(做了3年多u3d 这个都没用过),所以发誓要实现出来 ...

  7. 【Web API系列教程】1.2 — Web API 2中的Action Results

    前言 本节的主题是ASP.NET Web API怎样将控制器动作的返回值转换成HTTP的响应消息. Web API控制器动作能够返回下列的不论什么值: 1. void 2. HttpResponseM ...

  8. [WCF REST] 解决资源并发修改的一个有效的手段:条件更新(Conditional Update)

    条件获取(Conditional Update)可以避免相同数据的重复传输,进而提高性能.条件更新(Conditional Update)用于解决资源并发操作问题.如果我们预先获取一个资源进行修改或者 ...

  9. Web性能优化实践——应用层性能优化

    随着公司项目的进一步推广,用户数量的增加,已经面临着单台服务器不能负载的问题. 这次的优化由于时间关系主要分两步走,首先优化应用层代码以提高单台服务器的负载和吞吐率.之后再进行分表,引入队列.MemC ...

最新文章

  1. 学习web前端开发要注意什么
  2. java 调用c/c++
  3. SQL Server数据库大型应用解决方案总结(转载)
  4. C++设计模式--状态模式(state)
  5. 保存课程图片-服务端开发
  6. mysql查询后从高到低排序_[MySQL基础]三、排序查询
  7. 渲染服务器位置,如何用服务器做渲染
  8. Vue移动端项目——字体图标的使用
  9. OpenStack精华问答 | OpenStack的目标是什么?
  10. (100)FPGA RAM实现(V实现)
  11. 万物皆可Graph | 当信息检索遇上图神经网络
  12. Algorithms-Part1最后一周的作业——KdTree
  13. 我的开源项目:TS封装格式分析器
  14. linux+删除+grub,请问:如何删除grub引导
  15. django1.6 mysql_如何在Django1.6结合Python3.4版本中使用MySql
  16. 位移密码加密、解密matlab实现
  17. matlab连通区域质心标记,连通域的质心
  18. EB-Boost :智慧景区共享单车中长期投放量精准预测方法
  19. layui表格下拉框无法显示
  20. HTML+CSS聚光灯效果动画

热门文章

  1. 继承之接口知识点和思考练习
  2. java 导入excel到数据库_java导入excel到数据库
  3. java 递归从子节点删除父节点_LeetCode450. 删除二叉搜索树中的节点
  4. mysql中将某个字段做计算,mysql创建计算字段使用子查询教程
  5. Scude导入MySQL_FM2017_FMF赛季更新和真实修正数据库[更新至9.9,超过89000个更新]
  6. 虚拟机 java 开发_深入浅出 Java 虚拟机 · 通往高级 Java 开发的必经之路
  7. php设置排序,7种php基本排序实现方法
  8. android q升级名单,华为升级 Android Q 机型名单敲定 阵容庞大
  9. java的使用Pair要导入什么包,第三方jar包的使用
  10. 交华为换机access配置_华为交换机Hybrid接口及基础配置