开发者

Accessing the exact data sent using WebClient.UploadData on the server

Newbie question: I'm se开发者_高级运维nding 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


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"];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜