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