我有一个带有 IIS 7.5 和一个 IP 的 Windows 2008 服务器。根目录下有两个Application,/web 和/service。/web 是 MVC4 应用程序,/service 是 WCF 4.0 服务。
当我从 MVC 使用服务时,我使用以下代码:
// Create the web request
HttpWebRequest request = WebRequest.Create(TripServiceUrl + id) as HttpWebRequest;
// Get response
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
// Get the response stream
StreamReader reader = new StreamReader(response.GetResponseStream());
// Console application output
tripJson = reader.ReadToEnd();
}
我得到以下套接字异常:
[SocketException (0x274c): 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 10.243.6.43:80]
System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +273
System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) +584
但是,我可以从服务器上的浏览器中看到 10.243.6.43:80(内部地址)并成功调用该服务。该 IP 不可公开访问。
我应该做什么样的配置才能进行这样的自引用调用?