HttpStatusCode ' An Enumeration For the Web

I have posted before about IIS Status codes, realize that is not exactly a correct name for them, it should be Http Status Codes. I wanted to point you to a valuable enumeration in the System.Net namespace, HttpStatusCode. It contains members for each of the codes specific in RFC 2616 for HTTP 1.1, see page 57-71 or Section 10.

The HttpStatusCode enumeration should make it easier for .NET programmers to just program instead of looking up specific codes. One nice feature is the HttpWebResponse class has a Status property that implements the HttpStatusCode enumeration to do comparisons. This is really nice because it makes it pretty easy for a programmer to write a select case or switch statement (or an if statement if it warrants) to quickly route processing of the transaction based on the returned status code.

If myHttpWebResponse.StatusCode = HttpStatusCode.OK Then
    Console.WriteLine(ControlChars.Lf + ControlChars.NewLine + "Response Status Code is OK and StatusDescription is: {0}", myHttpWebResponse.StatusDescription)
End If


Share This Article With Your Friends!

We use cookies to give you the best experience possible. By continuing, we'll assume you're cool with our cookie policy.

Install Love2Dev for quick, easy access from your homescreen or start menu.

Googles Ads Facebook Pixel Bing Pixel LinkedIn Pixel