访问服务器上使用 WebClient.UploadData 发送的确切数据

发布于 2024-09-10 08:59:23 字数 327 浏览 3 评论 0原文

新手问题:我正在使用 WebClient.UploadData 方法将字节数组形式的大文本字符串发送到网站,但我不确定从服务器上的确切位置检索该数据。我读过一些帖子,说它位于我已经知道的请求对象中,但我到底如何检索我发送的特定字节数组,如以下 c# 伪代码所示:

byte[] dataSent = request.GettheByteArrayISentFromWebClientUploadDataMethod;

我知道它可能不像这个和那个那么简单我可能需要进行一些其他处理,但是任何人都可以发布一个代码片段来显示我如何获取发送的字节数组吗?

多谢多谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

叫思念不要吵 2024-09-17 08:59:23

尝试从请求流中读取它 Request.InputStream:

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

如果您要发送键/值对,则可以使用 UploadValues< /a> 方法并将它们简单地读取为请求参数:

string value = Request["someKey"];

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"];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文