tags:

views:

261

answers:

2

I need to check the RequestType of an HttpRequest in ASP.NET (or WebRequest.Method). I know that I can just use the string values "POST" or "GET" for the request type, but I could have sworn there was a constant somewhere in some class in .NET that contained the values.

Out of curiosity I was wondering if anyone knew what class these string constants for GET and POST were in. I've tried searching online but I've had no luck, so I thought I'd ask here.

+5  A: 
System.Net.WebRequestMethods.Http
    .Connect = "CONNECT"
    .Get = "GET"
    .Head = "HEAD"
    .MkCol = "MKCOL"
    .Post = "POST"
    .Put = "PUT"

Ultimately, though; since const expressions are burned into the caller, this is identical to using "GET" etc, just without the risk of a typo.

Marc Gravell
Exactly what I was looking for. Thanks!
Dan Herbert
+1  A: 

In ASP.NET MVC they're in System.Web.Mvc.HttpVerbs. But all methods that take one of these enum values also has a text override, as there is no complete set of HTTP verbs, only a set of currently defined values (see here and here and here).

You can't create an enumeration that covers all verbs, as there is the possibility that verbs can be added, and enumerations have versioning issues that make this impractical.

Will