Tag: httphandler文件

将块中的文件发送到HttpHandler

我正在尝试将块中的文件发送到HttpHandler但是当我在HttpContext中收到请求时,inputStream为空。 所以a:发送时我不确定我的HttpWebRequest是否有效而b:接收时我不知道如何在HttpContext中检索流 任何帮助非常感谢! 这是我如何从客户端代码发出请求: private void Post(byte[] bytes) { HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(“http://localhost:2977/Upload”); req.Method = “POST”; req.ContentType = “application/x-www-form-urlencoded”; req.SendChunked = true; req.Timeout = 400000; req.ContentLength = bytes.Length; req.KeepAlive = true; using (Stream s = req.GetRequestStream()) { s.Write(bytes, 0, bytes.Length); s.Close(); } HttpWebResponse res = (HttpWebResponse)req.GetResponse(); } 这就是我在HttpHandler中处理请求的方式: public void ProcessRequest(HttpContext context) { Stream chunk […]