I have an aspx page that I'm trying to make an httprequest and then setup a TCP socket(I think this is what I'm doing lol)... I'm needing to send a byte array through this. I have this code so far, any advice/tips? Huge errors you see? I removed some items for my privacy. Basically I'm trying to send a simple byte array. Any help is greatly appreciated as I'm new to TCP and HttpRequests and WebRequests. I have a Webrequest currently, and I'm not sure if that's what's causing this not to work.
byte[] buffer = { 254, 110, 1 };
WebRequest request = WebRequest.Create("httpaddress.aspx");
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = buffer.Length;
Stream PostData = request.GetRequestStream();
TcpClient ourMagicClient = new TcpClient();
ourMagicClient.Connect("DeviceIP", 2101);
NetworkStream ourStream = ourMagicClient.GetStream();
byte[] data = { 254, 109, 1 };
ourStream.Write(data, 0, data.Length);
PostData.Write(buffer, 0, buffer.Length);
PostData.Close();
HttpWebResponse WebResp = (HttpWebResponse)request.GetResponse();
Stream Answer = WebResp.GetResponseStream();
StreamReader _Answer = new StreamReader(Answer);
Console.WriteLine(_Answer.ReadToEnd());
Console.WriteLine(WebResp.StatusCode);
Console.WriteLine(WebResp.Server);
Console.WriteLine(_Answer.ReadToEnd());
Console.ReadKey();