RFC 2616指出:
Upon receiving a request which
includes an Expect request-header
field with the “100-continue” expectation,an origin server MUST
either respond with 100 (Continue) status and continue to read
from the input stream,or respond with a final status code. The
origin server MUST NOT wait for the request body before sending
the 100 (Continue) response. If it responds with a final status
code,it MAY close the transport connection or it MAY continue
to read and discard the rest of the request. It MUST NOT
perform the requested method if it returns a final status code.
这听起来像我需要对请求作出两个响应,即它需要立即发送一个HTTP 100继续响应,然后继续从原始请求流(即HttpContext.Request.InputStream)读取,而不会终止请求,然后最终发送结果的状态码(为了参数,让我们说这是一个204无内容的结果).
所以问题是:
我正在阅读规范,我需要对请求做出两个答复?
>如何在ASP.NET MVC中完成?
w.r.t. (2)在继续阅读输入流之前,我已尝试使用以下代码…
HttpContext.Response.StatusCode = 100; HttpContext.Response.Flush(); HttpContext.Response.Clear();
System.Web.HttpException: Server cannot set status after HTTP headers have been sent.