简体   繁体   English

DMZ服务器上的WebRequest.Create异常

[英]WebRequest.Create Exception on DMZ server

I'm not positive my issue is entirely code or a network issue, though not likely as my site works otherwise. 我不太肯定我的问题完全是代码或网络问题,尽管不太可能,因为我的网站无法正常工作。 In a round-about description, I've created a website that is hosted in the DMZ of my employer. 在回旋处,我创建了一个网站,该网站托管在我的雇主的DMZ中。 It's an MVC asp.net C# webform that submits test payment transaction data to a test production environment within the company. 这是一个MVC asp.net C#网络表单,可将​​测试付款交易数据提交到公司内部的测试生产环境。 A user fills in some fields, and presses the submit button in IE and IE takes over from there and displays the response from the internal test production server. 用户填写一些字段,然后在IE中按下提交按钮,然后IE从那里接管并显示来自内部测试生产服务器的响应。 So far, so good. 到现在为止还挺好。 Now..., I'm changing it so the submission goes through a Controller I have, grabbing the data and sending it to the same internal test production server where I'm now getting an exception on the 'Stream datastream...' line. 现在...,我正在对其进行更改,以便通过我拥有的Controller提交,获取数据并将其发送到同一内部测试生产服务器,在该服务器上我现在在“ Stream数据流...”上遇到异常。线。

              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.

The exception is: System.Net.Sockets.SocketException 例外是: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"

The TransactionData is a string. TransactionData是一个字符串。 Thanks in advance and let me know if more information is needed. 在此先感谢您,如果需要更多信息,请告诉我。

Solved. 解决了。 Turns out I needed to add a host entry pointing to the internal server! 原来,我需要添加一个指向内部服务器的主机条目! Maybe someone in the future will find this just as useful? 也许将来有人会发现这同样有用吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM