Streaming data TO web server from Windows Phone
It is possible to stream data from a Web Server using the HttpWebRequest class in Windows Phone 7.
Unfortunately Microsoft removed the ability to stream data to a web server using this class. The AllowWriteStreamBuffering property is not available on the phone.
Although you can write to the stream returned from EndGetRequestStream, the data only gets sent up to the server when you call BeginGetResponse. Which means that if you have a massive quantity of data to send, it will all be buffered in memory.
If you control the server side, you can split the message into several requests, but this isn't always the case.
It struck me that perhaps I could embed a hidden WebBrowser in my page, and then feed data to the browser using InvokeScript, and have the WebBrowser's Javascript stream the data.
Before I go down this (rather messy) route, I wanted 开发者_如何学编程to know if anyone else has tried this, and if so, what issues did you face?
This sounds like a world of pain....
Do you have any control over the protocol/software used on the server? If you do, then I think I'd change the protocol so you stream using a sequence of lots of HTTP requests rather than one big HTTP request.
Alternatively, if you can wait a couple of weeks, then something might be available in the new "Mango" tools release - it's definitely been suggested that Mango will "introduce support for TCP IP sockets" which hopefully will provide the sort of functionality you need.
精彩评论