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已经支持了
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相关推荐
- 转帖:HttpStatusCode状态说明C#版
Continue 等效于 HTTP 状态 100.Continue 指示客户端可能继续其请求. SwitchingProtocols 等效于 HTTP 状态 101.SwitchingProtocol ...
- C#在异常中获取HttpStatusCode用法
HttpStatusCode用法 catch (WebException e) {string status = null;HttpWebResponse response = (HttpWebRes ...
- 利用Node.js为Node.js生成HttpStatusCode辅助类并发布到npm
作为一个好的Restfull Api不仅在于service url的语义,可读性,幂等,正交,作为http状态码也很重要,一个好的Http Status Code给使用者一个很好的响应,比如200表示 ...
- 如何在asp.net mvc3中使用HttpStatusCode
下载了asp.net mvc 4的源码看了看,没怎么看清楚.不过个人觉得MVC4 beta中Web API这个是比较不错的,虽然说它是往传统回归. web api最好的莫过于它更加适合使用jquery ...
- WebApi2官网学习记录---异常处理
HttpResponseException 当WebAPI的控制器抛出一个未捕获的异常时,默认情况下,大多数异常被转为status code为500的http response即服务端错误. Http ...
- [原]unity3d之http多线程异步资源下载
郑重声明:转载请注明出处 U_探索 本文诞生于乐元素面试过程,被面试官问到AssetBundle多线程异步下载时,愣了半天,同样也被深深的鄙视一回(做了3年多u3d 这个都没用过),所以发誓要实现出来 ...
- 【Web API系列教程】1.2 — Web API 2中的Action Results
前言 本节的主题是ASP.NET Web API怎样将控制器动作的返回值转换成HTTP的响应消息. Web API控制器动作能够返回下列的不论什么值: 1. void 2. HttpResponseM ...
- [WCF REST] 解决资源并发修改的一个有效的手段:条件更新(Conditional Update)
条件获取(Conditional Update)可以避免相同数据的重复传输,进而提高性能.条件更新(Conditional Update)用于解决资源并发操作问题.如果我们预先获取一个资源进行修改或者 ...
- Web性能优化实践——应用层性能优化
随着公司项目的进一步推广,用户数量的增加,已经面临着单台服务器不能负载的问题. 这次的优化由于时间关系主要分两步走,首先优化应用层代码以提高单台服务器的负载和吞吐率.之后再进行分表,引入队列.MemC ...
最新文章
- 学习web前端开发要注意什么
- java 调用c/c++
- SQL Server数据库大型应用解决方案总结(转载)
- C++设计模式--状态模式(state)
- 保存课程图片-服务端开发
- mysql查询后从高到低排序_[MySQL基础]三、排序查询
- 渲染服务器位置,如何用服务器做渲染
- Vue移动端项目——字体图标的使用
- OpenStack精华问答 | OpenStack的目标是什么?
- (100)FPGA RAM实现(V实现)
- 万物皆可Graph | 当信息检索遇上图神经网络
- Algorithms-Part1最后一周的作业——KdTree
- 我的开源项目:TS封装格式分析器
- linux+删除+grub,请问:如何删除grub引导
- django1.6 mysql_如何在Django1.6结合Python3.4版本中使用MySql
- 位移密码加密、解密matlab实现
- matlab连通区域质心标记,连通域的质心
- EB-Boost :智慧景区共享单车中长期投放量精准预测方法
- layui表格下拉框无法显示
- HTML+CSS聚光灯效果动画
热门文章
- 继承之接口知识点和思考练习
- java 导入excel到数据库_java导入excel到数据库
- java 递归从子节点删除父节点_LeetCode450. 删除二叉搜索树中的节点
- mysql中将某个字段做计算,mysql创建计算字段使用子查询教程
- Scude导入MySQL_FM2017_FMF赛季更新和真实修正数据库[更新至9.9,超过89000个更新]
- 虚拟机 java 开发_深入浅出 Java 虚拟机 · 通往高级 Java 开发的必经之路
- php设置排序,7种php基本排序实现方法
- android q升级名单,华为升级 Android Q 机型名单敲定 阵容庞大
- java的使用Pair要导入什么包,第三方jar包的使用
- 交华为换机access配置_华为交换机Hybrid接口及基础配置