我正在开发一个 WinForms 应用程序,并希望将二进制图像数据发送到 Web 应用程序。它是如何工作的?
我编码了这个:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.AllowWriteStreamBuffering = true;
request.KeepAlive = true;
request.Credentials = System.Net.CredentialCache.DefaultCredentials;
var fc = GetFileContent(varsayilanResimGuid);
byte[] postBytes = fc.Dosya;
request.ContentLength = postBytes.LongLength;
Stream requestStream = request.GetRequestStream();
requestStream.Write(postBytes, 0, postBytes.Length);
requestStream.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
string content = new StreamReader(response.GetResponseStream()).ReadToEnd();
以及我如何在 .ashx 中接收此二进制图像内容?