Where is the constant for the values ​​"HttpRequest.RequestType" and "WebRequest.Method" in .NET?

I need to check RequestType 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 swear that the constant was somewhere in some kind of class in .NET containing the values.

Out of curiosity, I wondered if anyone knew in which class these string constants for GET and POST . I tried searching on the Internet, but I had no luck, so I thought I'd ask here.

+65
Nov 10 '08 at
source share
3 answers
 System.Net.WebRequestMethods.Http .Connect = "CONNECT" .Get = "GET" .Head = "HEAD" .MkCol = "MKCOL" .Post = "POST" .Put = "PUT" 

Ultimately, however; since const expressions are written to the caller, this is identical to using "GET", etc., without the risk of typos.

+91
Nov 10 '08 at
source

There is also System.Net.Http.HttpMethod , which can serve instead of listing. You can compare them aMethod == HttpMethod.Get etc. To get a call to the string method name, for example. HttpMethod.Get.Method .

+20
May 13 '15 at 8:30
source

In ASP.NET MVC they are in System.Web.Mvc.HttpVerbs . But all methods that take one of these enumeration values ​​also have text overrides, since there is no complete set of HTTP verbs, only a set of current values ​​(see here and here and here ).

You cannot create an enumeration that covers all verbs, since it is possible to add verbs, and enums have versioning problems that make this impractical.

+14
Nov 10 '08 at 14:21
source



All Articles