views:

66

answers:

1

I want to upload a file from a web application. The web application calls web services to access .NET classes, but it's not a .NET application itself.

What I want to do is this: upload a file from the web application, and call a separate .NET page to process and handle the uploaded file.

It would be easy to do this if I used a php script to process the uploaded file, but I particularly want to use .NET to process it.

Has anyone done this?

+3  A: 

Easy.

Request.Files

will handle that. To make it work, you should submit it as a valid HTML multipart/form-data POST request.

MSDN Library: HttpRequest.Files property

The other option is to post the entire file as the request body (which is probably easier from the sender application's perspective) and then use Request.BinaryRead method or Request.InputStream to process it. I've personally used the latter method in an application that needed to upload images to a Web server:

byte[] image = context.Request.BinaryRead(context.Request.ContentLength);
Mehrdad Afshari