加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net – HttpMethod和HttpRequest的RequestType有什么区别?

发布时间:2020-12-15 18:35:40 所属栏目:asp.Net 来源:网络整理
导读:HttpRequest类定义了两个属性: HttpMethod: Gets the HTTP data transfer method (such as GET,POST,or HEAD) used by the client. 06000 The HTTP data transfer method used by the client. 和RequestType: Gets or sets the HTTP data transfer method
HttpRequest类定义了两个属性:

HttpMethod:

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

06000

The HTTP data transfer method used by the client.

和RequestType:

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

06001

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

这两个属性有什么区别?我什么时候想要使用一个在另一个?检查哪个是客户端使用什么数据传输方法?

该文档指示HttpMethod将返回任何使用的动词:

such as GET,or HEAD

而RequestType上的文档似乎只表示两个可能的值之一:

GET or POST

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

测试:

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

有什么区别:

> HttpRequest.HttpMethod
> HttpRequest.RequestType

什么时候应该使用一个?

解决方法

Reflector显示RequestType在内部调用HttpMethod。所以你比HttpMethod调用更好一点。其实我觉得RequestType存在的真正原因是为了向后兼容经典的ASP。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读