无法建立连接,因为目标计算机被主动拒绝

时间:2016-06-02 16:48:13

标签: asp.net-mvc rest asp.net-mvc-4 asp.net-web-api

我是一个新的Asp.net Rest工作,我不知道如何解决这个问题,我已经在stackoverflow阅读了很多文章,没有人解决我的问题,我尝试了防火墙我尝试了互联网选项和其他的配置,我认为这个问题可能与令我困惑的事情有关,在运行我的客户端应用程序之前是否需要运行web服务?怎么做?因为我所做的只是编程我的休息应用程序然后我创建了我的asp.net mvc应用程序,我用这个帮助器连接到其余服务

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using System.Net.Http;
namespace ClienteMvcProdutos.Helpers
{
    public static class WebApiHttpClient
    {
        public const string WebApiBaseAddress = "http://localhost:25426/";
        public static HttpClient GetClient()
        {
            HttpClient client = new HttpClient();
            client.BaseAddress = new Uri(WebApiBaseAddress);
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(
            new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
            return client;
        }
    }
}

已经检查了端口并且它们已经匹配,已经更改了端口,它仍然无法工作,我有点desesperating:S这里是我的stacktrace

  

[SocketException(0x274d):Nenhumaligaçãopôdeserfeita porque o computador de destino   as recusou activamente 127.0.0.1:25426]      System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)+6604828      System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure,Socket s4,Socket s6,Socket& socket,IPAddress& address,ConnectSocketState state,IAsyncResult asyncResult,Exception& exception)+249

     

[WebException:无法连接到远程服务器]
  System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)   +606 System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)   64

     

[HttpRequestException:发送请求时发生错误。]
  System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务   任务)+92
  System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务   任务)+58 System.Runtime.CompilerServices.TaskAwaiter 1.GetResult() +28 ClientMvcProdutos.Controllers.<Index>d__1.MoveNext() in C:\Users\Filipe\Documents\Visual Studio 2015\Projects\ClientMvcProdutos\ClientMvcProdutos\Controllers\ProdutosController.cs:25 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58 System.Runtime.CompilerServices.TaskAwaiter.GetResult() +26 System.Threading.Tasks.TaskHelpersExtensions.ThrowIfFaulted(Task task) +42 System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute(IAsyncResult asyncResult) +73
System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeAsynchronousActionMethod>b__36(IAsyncResult asyncResult) +37
System.Web.Mvc.Async.WrappedAsyncResult
1.CallEndDelegate(IAsyncResult)   asyncResult)+27
  System.Web.Mvc.Async.WrappedAsyncResultBase 1.End() +58
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +68
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +34
System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d() +69 System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +230 System.Web.Mvc.Async.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult) +27
System.Web.Mvc.Async.WrappedAsyncResult
1.CallEndDelegate(IAsyncResult的   asyncResult)+27
  System.Web.Mvc.Async.WrappedAsyncResultBase 1.End() +58
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +68
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +34
System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +42 System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +124
System.Web.Mvc.Async.WrappedAsyncResult
1.CallEndDelegate(IAsyncResult的   asyncResult)+27
  System.Web.Mvc.Async.WrappedAsyncResultBase 1.End() +58
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +30
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +29
System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +27
System.Web.Mvc.Async.WrappedAsyncVoid
1.CallEndDelegate(IAsyncResult的   asyncResult)+48
  System.Web.Mvc.Async.WrappedAsyncResultBase 1.End() +58
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +30
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +21
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +32 System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +26
System.Web.Mvc.Async.WrappedAsyncVoid
1.CallEndDelegate(IAsyncResult的   asyncResult)+40
  System.Web.Mvc.Async.WrappedAsyncResultBase 1.End() +58
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +30
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +21 System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +29
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +24
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +27
System.Web.Mvc.Async.WrappedAsyncVoid
1.CallEndDelegate(IAsyncResult的   asyncResult)+48
  System.Web.Mvc.Async.WrappedAsyncResultBase`1.End()+58
  System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult,   对象标签)+30
  System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult,   对象标签)+21
  System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)   +29 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult)   结果)+23
  System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult的   ar)+129

0 个答案:

没有答案