什么是列举HTTPMethod之间和Htt的prequest的请求类型的区别? [英] What's the difference between HttpMethod and RequestType of HttpRequest?

查看:302
本文介绍了什么是列举HTTPMethod之间和Htt的prequest的请求类型的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

的<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.htt$p$pquest_properties.aspx\">Htt$p$pquest类定义了两个属性:

<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.htt$p$pquest.httpmethod.aspx\">HttpMethod:

HttpMethod:

获取客户端使用的HTTP数据传输方法(如GET,POST,或HEAD)。

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

public string HttpMethod { get; }  


  
  

由客户端所使用的HTTP数据传输方法。

The HTTP data transfer method used by the client.

RequestType:

and RequestType:

获取或设置HTTP数据传输方法(GET或POST)客户端使用。

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

public string RequestType { get; set; }

一个字符串,再presenting客户端发送的HTTP调用类型。

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?

文档表示的列举HTTPMethod 将返回期间使用的任何动词:

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

如GET,POST,HEAD或

such as GET, POST, or HEAD

而在文档的请求类型似乎表明只有两个可能值之一:

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

GET或POST

我与动词的随机抽样测试,这两个属性似乎支持所有动词,都返回相同的值:


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

测试:

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:


  • 的Htt prequest.HttpMethod

  • 的Htt prequest.RequestType

当我应该使用一个比其他?

and when should I use one over the other?

推荐答案

反射显示,请求类型要求列举HTTPMethod 内部。所以你的非常轻微的最好叫列举HTTPMethod 。其实我觉得真正的原因请求类型存在是为使用传统的ASP向后兼容性。

Reflector shows that RequestType calls HttpMethod internally. So you're ever so slightly better off calling HttpMethod. Actually I think the real reason RequestType exists was for backwards compatibility with classic ASP.

这篇关于什么是列举HTTPMethod之间和Htt的prequest的请求类型的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆