【发布时间】:2015-06-01 16:52:26
【问题描述】:
我正在将字节数组上传到 ASHX 处理程序
byte[] serializedRequest = SerializeRequest();
var uri = new Uri(_server.ActionUrl);
using (WebClient client = new WebClient())
{
client.UploadData(uri, serializedRequest);
}
处理程序接收到的内容
Dim str As Stream = context.Request.InputStream
Dim transformation(str.Length - 1) As Byte ' here I have extra "0"-byte
str.Position = 0
str.Read(transformation, 0, transformation.Length)
如你所见,我必须使用str.Length - 1 来声明字节数组。这正在开发中。我什至不知道它在部署时会如何表现。这个字节是从哪里来的?这是一种可靠的方法还是我应该在流的开头添加一些字节来告诉从 Request.InputStream 中读取多少字节?
【问题讨论】: