Get description for HTTP status code

jaap picture jaap · Aug 22, 2010 · Viewed 8.7k times · Source

In ASP.NET you can set the Response.StatusCode to for example 404. Should the status line / description always be set? (to in this case "404 Page Not Found")

How do you get the description if you only have the code (404)? Is this somewhere in the framework or do you manually have to hardcode the descriptions?

Answer

Ronald Wildenberg picture Ronald Wildenberg · Aug 22, 2010

You can use the static method HttpWorkerRequest.GetStatusDescription for this.