Get HTTP status code descriptions in ASP.Net Core

后端 未结 4 1837

In previous versions of ASP.Net, we could retrieve the description of a HTTP status code in a few ways as shown here:

Get description for HTTP status code

Is the

4条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-19 04:44

    This is close enough for my needs:

    var statusCode = httpContext.Response.StatusCode
    var description = ((HttpStatusCode)statusCode).ToString(); // 404 -> "NotFound"
    

提交回复
热议问题