c# - Using PushStreamContent to split data into chunks -
i have client written in angular 2, hits api returns large set of objects. want split can present data user work whilst loading rest in background.
from looking online @ ways stream data in request pushstreamcontent class seemed appropriate (open better suggestions). have been reading through tutorial http://blog.guvweb.co.uk/2014/07/02/streaming-web-api/
i have tried implemented basic example stream list of numbers test out.
at minute hitting api directly browser see if returns data. error message.
can tell me doing wrong?
my controller class
[route("numbers")] [httpget] public ihttpactionresult streamdata() { // generates list of numbers 1 --> 1,000,000 list<int> numbers = _dataaccess.generatenumbers(); var response = request.createresponse(); response.content = new pushstreamcontent( (stream, content, context) => { try { foreach (var num in numbers) { var serializer = new jsonserializer(); using (var writer = new streamwriter(stream)) { serializer.serialize(writer, num); stream.flush(); } } } { stream.close(); } }); return ok(response); }
doesn't mater found issue, own common sense culprit!
my browser downloading files , didn't see them, api stream works fine!
Comments
Post a Comment