本文介绍了为什么内容范围头从的ASP.NET Web API请求中去除?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个API,其中可以上传文件的分块的方式。

I'm creating an API in which it is possible to upload a file in a chunked manner.

展望本Stackoverflow问答,内容范围头似乎是最适合这个。

Going by this Stackoverflow question and answer, the content-range header seems most appropriate for this.

不过,在控制器动作头部已被去除,所以我不能访问它。当我使用'范围'头是在请求头货,

However, in the controller action the header has been stripped so I can't access it.When I use the 'range' header it is available in the request headers collection.

任何一个想法,为什么内容,范围是从请求中去除?

Anyone an idea why the Content-Range is stripped from Requests?

推荐答案

它不剥离。在Request.Content.Headers寻找它。看起来他们对准的HTTP头/ 1.1规格 - 移动实体头到Request.Content.Headers
我试图在一个示例请求,并发现它。

It is not stripped off. Look for it in Request.Content.Headers. It looks like they aligned the headers with the HTTP/1.1 specifications--moving Entity Headers to Request.Content.Headers.
I tried it in a sample request and found it there.

我发现读 2616 相关的章节后,这种变化。我已经打算在它最近因为主要作者,菲尔丁,也是REST架构风格的发明者,而我试图按照使用ASP.NET Web API中的风格。

I found this change after reading the relevant sections of RFC 2616. I've been going over it lately because the chief author, Fielding, is also the inventor of the REST architectural style, and I am trying to follow that style using ASP.NET Web API.

我意识到,有要求,回应,一般(关于请求和响应,但没有实体相关的使用)和实体标题之间的区别。

I realized that there was a distinction between "request", "response", "general" (used on both request and response but not entity related) and "entity" headers.

看起来好像ASP.NET团队修改后的类模型,以便更好地反映RFC,创造HttpHeaders三个子类:

Looks as if the ASP.NET team revised the class model to better mirror the RFC, creating three subclasses of HttpHeaders:

  • 的Htt prequestHeaders为5.3请求头域和4.5一般头字段
  • 的Htt presponsHeaders为6.2响应头字段和4.5一般头字段
  • HttpContentHeaders为7.1实体头字段
  • HttpRequestHeaders for "5.3 Request Header Fields" and "4.5 GeneralHeader Fields"
  • HttpResponsHeaders for "6.2 Response Header Fields" and "4.5 GeneralHeader Fields"
  • HttpContentHeaders for "7.1 Entity Header Fields"

这些都是MSDN中的三类逐字描述(链接是我的):

These are the verbatim descriptions of the three classes in MSDN (the links are mine):

请注意,尽管这MSDN类的描述是有点错误的 - 没有在RFC没有内容头部的定义,但很显然,他们的意思实体标题

Note, though that MSDN class description is a bit mistaken - there is no Content Headers definition in the RFC, but it is clear they meant Entity Headers.

这篇关于为什么内容范围头从的ASP.NET Web API请求中去除?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!