asp.net - HTTP 状态代码

标签 asp.net http

如何从 HttpStatusCode 对象获取 HTTP 状态代码 ID(在 ASP.NET 中? 例如,我得到“HttpStatusCode.NotFound”我想得到错误代码 404。

最佳答案

只需将其转换为 int 即可:

HttpStatusCode statusCode = HttpStatusCode.NotFound;
int codeAsInteger = (int)statusCode;

现在 codeAsInteger404

关于asp.net - HTTP 状态代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9328237/

相关文章:

c# - 向 System.Drawings.Color 添加颜色选项

asp.net - 将字节转换为图像 ASP.NET c# 并在 Image1.Url 中使用它

http - Angular2 中 Http 的 Promise 与 Observable?

c# - HTTP Expect Continue 性能

c - 如何使用 C 建立 HTTP 连接?

asp.net - 如何扩展/覆盖 mvc html.LabelFor

javascript - 禁用的文本框

c# - 如何获取paypal沙箱数据到我们的类(class)?

http - 如何让 uwsgi --http-to 能够同时处理多个响应?

javascript - 如何在 node.js 中终止的 http 连接上干净地关闭 FD