简体   繁体   中英

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

I am trying to implement streamed uploads using ServiceStack.

I followed the streaming uploads example linked from 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).

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).

Documentation does not provide any more information either:

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. It does not work when using ASP.NET host.

How to properly access the request stream using ServiceStack?

After long hours of debugging and analyzing the differences, I found out that the issue is with the VS Web Development server. Switching to IIS Express in Visual Studio settings fixed the issue - the RequestStream is not empty anymore.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM