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 there something similar to HttpWorkerRequest.GetStatusDescription
in ASP.Net Core?
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 there something similar to HttpWorkerRequest.GetStatusDescription
in ASP.Net Core?
This is close enough for my needs:
You can use
Microsoft.AspNetCore.WebUtilities.ReasonPhrases.GetReasonPhrase(int statusCode)
:Improving on the previous answer, you could split
HttpStatusCode
enum name with spaces, e.g.:Or if you prefer regular expressions:
Also you can simplify it to just this:
Looking at the enum key names they seem to be pretty reasonably named so most, if not all, status codes should yield acceptable reason messages.