そのため、GET 要求でバイト配列を書き込む asp.net アプリケーションがあり、C# アプリケーションでそのバイト配列を受信しようとしています。しかし、ヘッダーをダウンロードしようとすると、ヘッダーしか受信しないようです。(合計バフ)
私は説明するのが得意ではありませんが、コードがより明確になることを願っています。
ASP.NET コード:
var resp = new HttpResponseMessage(HttpStatusCode.OK);
resp.Content = new StreamContent(new FileStream("D:\\Temp\\uLockStub.dll", FileMode.Open));
resp.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
return resp;
C# コード:
var httpReq = (HttpWebRequest)
WebRequest.Create(string.Format("http://localhost:48976/login/login?user={0}&password={1}&hwid={2}",
username, Helper.GetMd5Hash(password), uid));
var resp = httpReq.GetResponse();
var data = resp.GetResponseStream();
var buff = new byte[1024];
var totalBuff = new List<byte>();
var read = 0;
while ((read = data.Read(buff, 0, buff.Length)) > 0)
{
var tmpBuff = new byte[read];
Buffer.BlockCopy(buff, 0, tmpBuff, 0, read);
totalBuff.AddRange(tmpBuff);
}
私は何を間違っていますか?
前もって感謝します!