Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net HTTP状态代码_Asp.net_Http - Fatal编程技术网

Asp.net HTTP状态代码

Asp.net HTTP状态代码,asp.net,http,Asp.net,Http,如何从HttpStatusCode的对象(在ASP.NET中)获取HTTP状态代码id? 例如,我得到“HttpStatusCode.NotFound”,我想得到错误代码404。将其转换为整数 (int)HttpStatusCode.NotFound 只需将其转换为int: HttpStatusCode statusCode = HttpStatusCode.NotFound; int codeAsInteger = (int)statusCode; 现在codeAsInteger是404谢

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

将其转换为整数

(int)HttpStatusCode.NotFound

只需将其转换为
int

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

现在
codeAsInteger
404

谢谢,我真的很轻松