Thursday 23 June 2011

Ranges header with Silverlight HttpWebRequest

Trying to download a large piece of content, and using the Ranges header to do a pause/resume feature or recover from a network problem during download ?
If you're using Silverlight, and using the HttpWebRequest, you'll find that the Ranges header is not allowed! WTF Silverlight team ?

All is not lost though - more magic settings come to your aid. Before creating the request, add these two magic little lines :

WebRequest.RegisterPrefix("http://", WebRequestCreator.ClientHttp);
WebRequest.RegisterPrefix("https://", WebRequestCreator.ClientHttp);

This works in SL4 (think it works in SL3 too)

No comments:

Post a Comment