简体   繁体   English

如何将流发送到ServiceStack? (使用IRequiresRequestStream时,RequestStream的长度始终为零)

[英]How to send stream to ServiceStack? (RequestStream always has zero length when using IRequiresRequestStream)

I am trying to implement streamed uploads using ServiceStack. 我正在尝试使用ServiceStack实现流式上传。

I followed the streaming uploads example linked from ServiceStack wiki ( http://www.codeproject.com/Articles/501608/Sending-Stream-to-ServiceStack ). 我遵循了从ServiceStack Wiki( http://www.codeproject.com/Articles/501608/Sending-Stream-to-ServiceStack )链接的流上传示例。

The problem is that on the Service side, the request stream is always empty (Length=0). 问题在于,在服务端,请求流始终为空(长度= 0)。

Same applies for base.Request.InputStream accessed in the Service processing the POST method (actually the stream instances are the same for Request.InputStream and the IRequiresRequestStream.RequestStream property). 同样适用于在处理POST方法的Service中访问的base.Request.InputStream (实际上,流实例对于Request.InputStream和IRequiresRequestStream.RequestStream属性是相同的)。

Documentation does not provide any more information either: 文档也不提供任何更多信息:

https://github.com/ServiceStack/ServiceStack/wiki/Serialization-deserialization#reading-directly-from-the-request-stream https://github.com/ServiceStack/ServiceStack/wiki/Serialization-deserialization#reading-directly-from-the-request-stream

EDIT: It works when using the exact solution from codeproject which uses console based AppHost. 编辑:当使用来自基于控制台的AppHost的codeproject中的确切解决方案时,它可以工作。 It does not work when using ASP.NET host. 使用ASP.NET主机时,它不起作用。

How to properly access the request stream using ServiceStack? 如何使用ServiceStack正确访问请求流?

After long hours of debugging and analyzing the differences, I found out that the issue is with the VS Web Development server. 经过长时间的调试和分析差异后,我发现问题出在VS Web开发服务器上。 Switching to IIS Express in Visual Studio settings fixed the issue - the RequestStream is not empty anymore. 在Visual Studio设置中切换到IIS Express可以解决此问题-RequestStream不再为空。

To change the setting, go to Project properties -> Web tab, under Servers, pick Use Local IIS Web server instead of the default Use Visual Studio Development Server 若要更改设置,请转到“ Project properties ->“ Web选项卡,在“服务器”下,选择“ Use Local IIS Web server而不是默认的“ Use Visual Studio Development Server

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 [http]未指定content-length时如何识别流的结尾? - [http]How to identify end of stream when content-length is not specified? ServiceStack-将文件作为字节流上传? - ServiceStack - upload files as byte stream? 当内容长度为零时,强制读取HttpWebResponse.GetResponseStream() - Force To Read HttpWebResponse.GetResponseStream() When Content-Length Is Zero 为什么有些服务器在最后一个块长度为零后不使用 CRLF? - Why are some servers not using CRLF after the last chunk length of zero? 如何在没有Content-Length标头的情况下流式传输HTTP文件? - How to stream an HTTP file upload without the Content-Length header? 使用HTML表单时如何在HTTP请求正文中发送数据? - How to send data in the HTTP request body when using an HTML form? 如何使用Perl为HTTP请求发送不正确的Content-Length标头? - How can I send an incorrect Content-Length header for an HTTP request using Perl? 是否可以在长时间运行的请求中通过ServiceStack流式传输部分结果? - Is it possible to stream partial results through ServiceStack on a long running request? 如何使用 Proxygen 和 Folly 发送 HTTP 分块响应以模拟视频流? - How to send HTTP chunked response to emulate a video stream using Proxygen and Folly? 使用http压缩时的内容长度 - content-length when using http compression
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM