我不是肯定的,我的问题完全是代码或网络问题,但不太可能,因为我的网站无效。在一个概括的描述中,我创建了一个托管在我雇主的DMZ中的网站。它是一个MVC asp.net C#webform,它将测试支付交易数据提交给公司内的测试生产环境。用户填写一些字段,按IE中的提交按钮,IE从那里接管并显示内部测试生产服务器的响应。到现在为止还挺好。现在......,我正在更改它,以便提交通过我拥有的控制器,抓取数据并将其发送到相同的内部测试生产服务器,我现在在&#39上获得例外;流数据流...'线。
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(selectedServer); // Create a request using a URL that can receive a post.
request.Method = "POST"; // Set the Method property of the request to POST.
byte[] byteArray = Encoding.UTF8.GetBytes(TransactionData);
request.ContentType = "application/x-www-form-urlencoded"; // Set the ContentType property of the WebRequest.
request.ContentLength = byteArray.Length; // Set the ContentLength property of the WebRequest.
Stream dataStream = request.GetRequestStream(); // Get the request stream.
dataStream.Write(byteArray, 0, byteArray.Length); // Write the data to the request stream.
dataStream.Close(); // Close the Stream object.
WebResponse response = request.GetResponse(); // Get the response.
例外是:System.Net.Sockets.SocketException
"A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 'some.ip.address.255:7969' at System.Net"
TransactionData是一个字符串。 提前致谢,如果需要更多信息,请告诉我。
答案 0 :(得分:0)
解决。结果我需要添加一个指向内部服务器的主机条目! 也许将来某人会发现这同样有用吗?