Alex Rivera | Logout

Download file from webservice - in ASP.NET site

Asked 2010-02-10T19:16:49.907
11

I want to push a file to the browser from a website using a webservice. I'm currently reading the file into a base64 byte array, and returning that from the webservice. This webservice is called from a website, and i'm stuck on how to push this as the original file to the browser. Ideally I would like to read the byte array into a memory stream, and then just write it to the Response stream if possible so the end user just downloads the file.

Edit
Report

1 Answer

1

Its usually a bad idea to embed a file in a web service. You just add overhead and complexity with no real benefit.

Instead you should provide a IHttpHandler to handle the file upload. Most web servers also provide helper API's to simplify this, e.g. in ASP.NET you can access the uploaded file with:

HttpContext.Request.Files[0]

There are plenty of javascript file upload scripts that simplify this on the client: http://www.phpletter.com/Demo/AjaxFileUpload-Demo/

answered 2010-02-10T19:28:59.883

Your Answer