[英]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.