views:

17

answers:

2

Hey All,

Newbie question: I'm sending a large text string in the form of a byte array using the WebClient.UploadData method to a web site but I'm not sure exactly where to retrieve that data from on the server. I've read posts that say it is in the request object which I already know but how exactly do I retrieve the specific byte array I sent like in the following c# pseudo code:

byte[] dataSent = request.GettheByteArrayISentFromWebClientUploadDataMethod;

I understand that it may not be as simple as this and that I may need to do some other processing but can anyone post a code snippet that shows how I can get at the byte array that was sent?

Mucho Thank-you

A: 

Try reading it from the request stream Request.InputStream:

var bytes = new byte[request.InputStream.Length];
Request.InputStream.Read(bytes, 0, bytes.Length);

If you are sending key/value pairs then you could use the UploadValues method and read them simply as request paraneters:

string value = Request["someKey"];
Darin Dimitrov
Thanks for the response. It worked but it raises a couple of other questions: is there a limit to the amount of data that can be passed using this method and is there a danger of any other data being added to the InputStream as it makes it's way to the server?
fynnbob
A: 

Request.BinaryRead

rick schott