无法建立连接,因为目标计算机主动拒绝它127.0.0.1:27681

时间:2015-12-04 12:59:37

标签: c# asp.net-mvc asp.net-web-api entity-framework-6

我的项目是使用visual studio 2015(.Net framework:4)开发的Asp.Net网站。

它是一个WebApi和MVC二合一项目,并且在我的开发机器上运行良好。但是在另一台笔记本电脑和smarterASP免费托管上发布后,我在有数据库调用的页面上收到此错误(实体框架6)

  

无法建立连接,因为目标计算机主动拒绝了它127.0.0.1:27681

     

在执行当前Web请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪来识别有关异常的起源和位置的信息。

     

[SocketException(0x274d):无法建立连接,因为目标计算机主动拒绝它127.0.0.1:27681]          System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)+6769080          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(任务任务)+99          System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+58          Lewisham.Controllers.d__1.MoveNext()+293          System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)+99          System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+58          System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute(IAsyncResult asyncResult)+97          System.Web.Mvc.Async。<> c__DisplayClass37.b__36(IAsyncResult asyncResult)+17          System.Web.Mvc.Async.WrappedAsyncResult1.CallEndDelegate(IAsyncResult asyncResult)+10          System.Web.Mvc.Async.WrappedAsyncResultBase1.End()+49          System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)+32          System.Web.Mvc.Async.AsyncInvocationWithFilters.b__3d()+50          System.Web.Mvc.Async。<> c__DisplayClass46.b__3f()+225          System.Web.Mvc.Async。<> c__DisplayClass33.b__32(IAsyncResult asyncResult)+10          System.Web.Mvc.Async.WrappedAsyncResult1.CallEndDelegate(IAsyncResult asyncResult)+10          System.Web.Mvc.Async.WrappedAsyncResultBase1.End()+49          System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult)+34          System.Web.Mvc.Async。<> c__DisplayClass2b.b__1c()+26          System.Web.Mvc.Async。<> c__DisplayClass21.b__1e(IAsyncResult asyncResult)+100          System.Web.Mvc.Async.WrappedAsyncResult1.CallEndDelegate(IAsyncResult asyncResult)+10          System.Web.Mvc.Async.WrappedAsyncResultBase1.End()+49          System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult)+27          System.Web.Mvc.Controller.b__1d(IAsyncResult asyncResult,ExecuteCoreState innerState)+13          System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult)+29          System.Web.Mvc.Async.WrappedAsyncResultBase1.End()+49          System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)+36          System.Web.Mvc.Controller.b__15(IAsyncResult asyncResult,Controller controller)+12          System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult)+22          System.Web.Mvc.Async.WrappedAsyncResultBase1.End()+49          System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult)+26          System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult)+10          System.Web.Mvc.MvcHandler.b__5(IAsyncResult asyncResult,ProcessRequestState innerState)+21          System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult)+29          System.Web.Mvc.Async.WrappedAsyncResultBase1.End()+49          System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)+28          System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result)+9          System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar)+129

当我在本地运行站点时,数据库连接指向远程数据库,它正常工作。

1 个答案:

答案 0 :(得分:0)

问题是,我没有更改REST URL以匹配托管URL。这就是为什么它不适用于任何机器而不是我的开发机器。

感谢所有人的贡献。

相关问题