Asp.Net错误:无法建立连接,因为目标计算机主动拒绝它

时间:2011-05-23 05:31:39

标签: asp.net iis-7.5

每当我尝试执行System.Net.HttpWebRequest.GetRequestStream()时,无论我调用的是什么URL,我都会收到以下错误:

Exception Type: System.Net.WebException   
Message: Unable to connect to the remote server
Source: System

Stack Trace: 
   at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
   at System.Net.HttpWebRequest.GetRequestStream()
   at WorldVision.Sitefinity.Data.Business.WebServices.Viocorp.PreparePostRequest(WebRequest webRequest, NameValueCollection parameters) in c:\Inetpub\Websites\WvaFEGit\CmsWebsite\WorldVision.Sitefinity.Data\Business\WebServices\Viocorp.cs:line 167
   at WorldVision.Sitefinity.Data.Business.WebServices.Viocorp.QueryWithParameters(ServiceType service, NameValueCollection parameters) in c:\Inetpub\Websites\WvaFEGit\CmsWebsite\WorldVision.Sitefinity.Data\Business\WebServices\Viocorp.cs:line 109
   at WorldVision.Sitefinity.Data.Business.WebServices.Viocorp.QueryWithParameters(String serviceName, NameValueCollection parameters) in c:\Inetpub\Websites\WvaFEGit\CmsWebsite\WorldVision.Sitefinity.Data\Business\WebServices\Viocorp.cs:line 87
   at WorldVision.Sitefinity.Data.Business.VioCorpVideoRepository.GetVideoByMediaId(String mediaId) in c:\Inetpub\Websites\WvaFEGit\CmsWebsite\WorldVision.Sitefinity.Data\Business\IVioCorpVideoRepository.cs:line 28
   at WorldVision.Sitefinity.Modules.Story.WebControls.Design.VioCorpVideoControlDesigner.BindPresentation() in c:\Inetpub\Websites\WvaFEGit\CmsWebsite\WorldVision.Sitefinity.Modules\Story\WebControls\Design\VioCorpVideoControlDesigner.cs:line 143
   at WorldVision.Sitefinity.Modules.Story.WebControls.Design.VioCorpVideoControlDesigner.BindVideo() in c:\Inetpub\Websites\WvaFEGit\CmsWebsite\WorldVision.Sitefinity.Modules\Story\WebControls\Design\VioCorpVideoControlDesigner.cs:line 136
   at WorldVision.Sitefinity.Modules.Story.WebControls.Design.VioCorpVideoControlDesigner.Button_Command(Object sender, CommandEventArgs e) in c:\Inetpub\Websites\WvaFEGit\CmsWebsite\WorldVision.Sitefinity.Modules\Story\WebControls\Design\VioCorpVideoControlDesigner.cs:line 187
   at System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e)
   at System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument)
   at System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
   at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
   at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
------------------------------------------------------------------------------------
- L1 -------------------------------------------------------------------------------

Exception Type: System.Net.Sockets.SocketException

Message: No connection could be made because the target machine actively refused it 210.247.216.66:80

Source: System

Stack Trace: 
   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
------------------------------------------------------------------------------------

我查看了来自两个不同提供商的两个不同的网址,除了IP地址不同外,我得到了完全相同的错误。

我已经检查了防火墙设置,IIS设置和服务器设置,没有什么突出的。

更糟糕的是,代码在使用IIS 7.5的外部服务器上运行,但配置相同,但在内部服务器上失败。

我还将内部IP地址添加到两个提供商的可接受列表中。

因此,代码在外部工作,而不是在内部工作。代码没有任何区别。

有什么想法吗?

2 个答案:

答案 0 :(得分:1)

你认为这个例外是骗你的吗?

“目标计算机主动拒绝它”意味着目标计算机收到了连接请求,但决定拒绝它而不是接受它。这几乎总是意味着在请求的端口上没有任何监听。我想这可能意味着有一些东西正在倾听,它看到了连接请求,并明确地拒绝了它。

您需要从“目标计算机”中找出它“主动拒绝”连接尝试的原因。

答案 1 :(得分:0)

从麻烦的机器命令提示符处尝试:

telnet 55.55.55.55 80

55.55.55.55表示远程主机的IP地址。在包括80(端口)之前,请确保在其后面加一个空格。

如果telnet无法连接,那么您的应用程序和主机应用程序之间肯定存在问题 - 可能是防火墙或相关问题。

如果telnet可以连接,但你的应用程序仍然无法连接,那么你已经合法地将它缩小到一个非常小的东西(应用程序)。

其他提示: