.NET: What's the difference between HttpMethod and RequestType of HttpRequest?

Posted by Ian Boyd on Stack Overflow See other posts from Stack Overflow or by Ian Boyd
Published on 2010-01-28T18:18:37Z Indexed on 2010/04/08 6:43 UTC
Read the original article Hit count: 395

Filed under:
|
|
|
|

The HttpRequest class defines two properties:

HttpMethod:

Gets the HTTP data transfer method (such as GET, POST, or HEAD) used by the client.

public string HttpMethod { get; }

The HTTP data transfer method used by the client.

and RequestType:

Gets or sets the HTTP data transfer method (GET or POST) used by the client.

public string RequestType { get; set; }

A string representing the HTTP invocation type sent by the client.

What is the difference between these two properties? When would i want to use one over the other? Which is the proper one to inspect to see what data transfer method was used by the client?

The documentation indicates that HttpMethod will return whatever verb was used:

such as GET, POST, or HEAD

while the documentation on RequestType seems to indicate only one of two possible values:

GET or POST


i test with a random sampling of verbs, and both properties seem to support all verbs, and both return the same values:

Testing:

Client Used    HttpMethod    RequestType
GET            GET           GET
POST           POST          POST
HEAD           HEAD          HEAD
CONNECT        CONNECT       CONNECT
MKCOL          MKCOL         MKCOL
PUT            PUT           PUT
FOOTEST        FOOTEST       FOOTEST

What is the difference between:

  • HttpRequest.HttpMethod
  • HttpRequest.RequestType

and when should i use one over the other?

Keywords: iis asp.net http httprequest httphandler

© Stack Overflow or respective owner

Related posts about iis

Related posts about ASP.NET