Opening response stream in silverlight

Posted by John Maloney on Stack Overflow See other posts from Stack Overflow or by John Maloney
Published on 2010-03-24T22:39:25Z Indexed on 2010/03/24 22:43 UTC
Read the original article Hit count: 261

Hello, I am attempting to return a image from a server using Silverlight 3. The server returns the Response stream like this:

 context.Response.ContentType = imageFactory.ContentType
 imgStream.WriteTo(context.Response.OutputStream)
 imgStream.Close()
 context.Response.End()

On the Silverlight client I am handling the stream like:

    Dim request As HttpWebRequest = result.AsyncState
    Dim response As HttpWebResponse = request.EndGetResponse(result)
    Dim responseStream As IO.Stream = response.GetResponseStream()

I want to take that stream and open the browsers save dialog, one option I have explored is using the Html.Window.Navigate(New Uri("image url")) and this opened the correct browser default dialog but it is not an option because I need to send extended information(e.g. XML) to the server through the HttpRequest.Headers.Item and the Navigate doesn't allow this.

How can I take a Response Stream and force the default browser Save dialog to appear from the Silverlight Application without using the Html.Window.Navigate(New Uri("image url"))?

© Stack Overflow or respective owner

Related posts about silverlight-3.0

Related posts about httpresponse