无法建立连接,因为目标计算机主动拒绝它xxx.x.x.x:xxxx [英] No connection could be made because the target machine actively refused it xxx.x.x.x:xxxx

查看:167
本文介绍了无法建立连接,因为目标计算机主动拒绝它xxx.x.x.x:xxxx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows 10上运行此应用程序。



我尝试过:



i刚刚创建了一个简单的空ASP.Net Web应用程序,并在此文件中添加了一个名为HelloWebService.asmx的Web服务,创建了一个名为GetMessage的方法,其中包含单个参数,如下所示: />

 public class HelloWebServices:System.Web.Services.WebService 
{
[WebMethod]
public string Getmessage(string name)
{
返回Hello World+名称;
}
}



之后我创建了一个名为HelloWebClient的空ASP.NET Web应用程序并添加到此WebForm1.aspx使用以下代码在HelloWebServices中调用GetmessageWeb方法。

公共部分类WebForm1:System.Web.UI.Page 
{
protected void Button1_Click(object sender,EventArgs e)
{
HelloWebService.HelloWebServicesSoapClient client = new
HelloWebService.HelloWebServicesSoapClient();

Label1.Text = client.Getmessage(TextBox1.Text);
}
}



之后,我将一个ServiceReferenceHellowWebservice添加到HelloWebClient。



现在我正在运行应用程序并单击获取消息按钮,我收到以下错误。请指教并帮助我解决这个问题。



确切的错误在行中:120返回base.Channel.Getmessage(请求);

'/'应用程序中的服务器错误。



由于目标机器主动拒绝它,因此无法建立连接127.0.0.1:51537



描述:执行当前Web请求期间发生了未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。



异常详细信息:System.Net.Sockets.SocketException:无法建立连接,因为目标计算机主动拒绝它127.0.0.1:51537



来源错误:



第118行:[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState) .Advanced)] 
第119行:helloWebClient.HelloWebService.GetmessageResponse helloWebClient.HelloWebService.HelloWebServicesSoap.Getmessage(helloWebClient.HelloWebService.GetmessageRequest request){
第120行:return base.Channel.Getmessage(request);
第121行:}
第122行:

解决方案

检查 .config 文件,主要是这个错误是由错误的端口号码或错误的PC名称引起的(如果您在一台PC上测试所有内容,则应该 localhost )。

I am runnig this application on windows 10.

What I have tried:

i Just created a simple "Empty ASP.Net web application" and added a web services named as "HelloWebService.asmx" within this file created a single method called as "GetMessage" with single parameter as follows:

public class HelloWebServices : System.Web.Services.WebService
    {
        [WebMethod]
        public string Getmessage( string name)
        {
            return "Hello World " + name;
        }
    }


After that i created one more "Empty ASP.NET Web Application" with the name "HelloWebClient" and added to this a "WebForm1.aspx" with the following code to call the "Getmessage" web method in the "HelloWebServices".

public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Button1_Click(object sender, EventArgs e)
        {
            HelloWebService.HelloWebServicesSoapClient client = new 
            HelloWebService.HelloWebServicesSoapClient();

            Label1.Text = client.Getmessage(TextBox1.Text);
        }
    }  


After that, i add a ServiceReference "HellowWebservice" to the "HelloWebClient".

Now i am running the application and click on the "Get Message" button and i am getting the below error. please advise and help me to solve this issue.

The exact error is in the line : 120 return base.Channel.Getmessage(request);
Server Error in '/' Application.

No connection could be made because the target machine actively refused it 127.0.0.1:51537

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:51537

Source Error:

Line 118:        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
Line 119:        helloWebClient.HelloWebService.GetmessageResponse helloWebClient.HelloWebService.HelloWebServicesSoap.Getmessage(helloWebClient.HelloWebService.GetmessageRequest request) {
Line 120:            return base.Channel.Getmessage(request);
Line 121:        }
Line 122:        

解决方案

Check your .config files, mostly this error is caused by a wrong port number, or incorrect name of the PC (which should be localhost if you are testing everything on one PC).


这篇关于无法建立连接,因为目标计算机主动拒绝它xxx.x.x.x:xxxx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆