Need help passing image using webservice

mjdeslon

New member
Joined
Apr 12, 2012
Messages
1
Programming Experience
5-10
Hello,

I have a issue I am hoping the community can help me with.

I am trying to allow the user to download a file stored on a server using a web service. Here is my code...

VB.NET:
fFile = New System.IO.FileInfo(Path.Combine(strPath, strFile))
            If Not fFile Is Nothing Then
                If fFile.Exists Then
                    Response.Clear()
                    Response.ContentType = "application/octet-stream"
                    Response.AppendHeader("Content-Disposition", "attachment; filename=" + strFile)
                    Return successMessage
                    Response.TransmitFile(Server.MapPath(fFile.FullName))
                    Response.End()
                    Return successMessage
                Else
                    Return failMessage
                End If
            Else
                Return failMessage
            End If

The error I am getting is "Response is not available in this context." I know it is because I am trying to use Httpresponse from a webservice...but I need to know how to make it work...

Thanks for your time!
Michael
 
You'll need to serialize the image to a format that the end-user can handle. A quick google of 'serialize image from webservice' gave me this - Binary Serialization and BinaryFormatter with WebServices ... it's in C# and not overly complex, but should also give you enough of a starting point to find alternatives.
 
Back
Top