Results 1 to 2 of 2

Thread: Need help passing image using webservice

  1. #1
    mjdeslon is offline VB.NET Forum Newbie
    .NET Framework
    .NET 4.0
    Join Date
    Apr 2012
    Posts
    1
    Reputation
    0

    Need help passing image using webservice

    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...

    Code:
    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

  2. #2
    Menthos is offline VB.NET Forum Master
    .NET Framework
    .NET 3.5
    Join Date
    Jul 2006
    Posts
    272
    Reputation
    171
    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.
    A friend will help you move. A real friend will help you move a body.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Harvest time tracking