Twilio clicktocall-csharp - 首次启动后出现内部500错误

时间:2017-08-22 18:05:22

标签: c# twilio

设置正确的“TwilioAccountSID”,“TwilioAuthToken”和“TwilioNumber”后,网页上显示“调用您时出现问题 - 请稍后再试”。我可以在其他应用程序中使用其他Twilio功能,但ClickToCall无法正常工作。它不会拨出任何一个号码。

示例项目: https://github.com/TwilioDevEd/clicktocall-csharp

Error Message

Firefox中的控制台日志:

  

不推荐使用getPreventDefault()。使用defaultPrevented   代替。 jquery-1.10.2.js:5375:28 XML解析错误:没有根元素   发现位置:   http://localhost:57471/01d55b0057f14d8aa4f39e67f234bae7/browserLinkSignalR/abort?transport=webSockets&connectionToken=AQAAANCMnd8BFdERjHoAwE%2FCl%2BsBAAAA9nnpT%2Bd2GEGGBvJN2iSr%2FAAAAAACAAAAAAAQZgAAAAEAACAAAAA5C0avgoOxzy0g8wtuZzNLaBQla80xMib%2FzC%2Ft9UuALwAAAAAOgAAAAAIAACAAAAAVgVKnWONXBwpQ%2FQynRYyeKOOZw8ZnvXuTf7SIoOTAGDAAAAD7kYmTiT%2FoNJJMIKh5KrXfhkyBndCsBDP4QnpepbcwWc6o30MXPHYCyAiJwt2Dy2pAAAAAQWB%2BSLeKghpSzeaKqUHL7LVhQ8%2FfLiCtjRL9V%2BL03xElOpifAfuaJ2NzMxckwj2z3BoQ%2BCb7lW9A6zBQMPSXGQ%3D%3D&requestUrl=http%3A%2F%2Flocalhost%3A1430%2F&browserName=Firefox&userAgent=Mozilla%2F5.0+(Windows+NT+10.0%3B+WOW64%3B+rv%3A54.0)+Gecko%2F20100101+Firefox%2F54.0   第1行,第1列:中止:1:1 POST XHR   http://localhost:1430/CallCenter/Call [HTTP / 1.1 500内部服务器   错误18ms]标头POST响应调用堆栈   缓存ControlprivateContent-Length12174Content-的TypeText / HTML;   charset = utf-8DateTue,2017年8月22日17:26:58   GMTServerMicrosoft-IIS / 10.0X-ASPNET-Version4.0.30319X供电-ByASP.NETX-SourceFiles =?UTF-8 2 B 4 QzpcVXNlcnNcUmhvZGVzXERvd25sb2Fkc1xjbGlja3RvY2FsbC1jc2hhcnAtbWFzdGVyICgxKVxjbGlja3RvY2FsbC1jc2hhcnAtbWFzdGVyXENsaWNrVG9DYWxsLldlYlxDYWxsQ2VudGVyXENhbGw =?=   Acceptapplication / json,text / javascript,/; Q = 0.01Accept-Encodinggzip,   deflateAccept-Languageen-US,EN; Q = 0.5Connectionkeep-aliveContent-Length52Content-Typeapplication / X WWW的窗体-urlencoded;   charset = UTF-8Hostlocalhost:1430Refererhttp:// localhost:1430 / User-AgentMozilla / 5.0(Windows NT 10.0; WOW64; rv:54.0)Gecko / 20100101   火狐/ 54.0X请求-WithXMLHttpRequest

换行符67:

enter image description here

计算机日志:

Event code: 3005 
Event message: An unhandled exception has occurred. 
Event time: 8/24/2017 11:53:34 AM 
Event time (UTC): 8/24/2017 3:53:34 PM 
Event ID: 9b90d28d894f41a09a832ce672308828 
Event sequence: 13 
Event occurrence: 1 
Event detail code: 0 

Application information: 
    Application domain: /LM/W3SVC/2/ROOT-1-131480635887199949 
    Trust level: Full 
    Application Virtual Path: / 
    Application Path: C:\Users\Rhodes\Documents\Visual Studio 2017\Projects\clicktocall-csharp-master\ClickToCall.Web\ 
    Machine name: DEV-103 

Process information: 
    Process ID: 74140 
    Process name: iisexpress.exe 
    Account name: DEV-103\Rhodes 

Exception information: 
    Exception type: NullReferenceException 
    Exception message: Object reference not set to an instance of an object.
   at ClickToCall.Web.Controllers.CallCenterController.<>c__DisplayClass7_0.<IsProduction>b__0(String domain) in C:\Users\Rhodes\Documents\Visual Studio 2017\Projects\clicktocall-csharp-master\ClickToCall.Web\Controllers\CallCenterController.cs:line 68
   at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate)
   at ClickToCall.Web.Controllers.CallCenterController.IsProduction() in C:\Users\Rhodes\Documents\Visual Studio 2017\Projects\clicktocall-csharp-master\ClickToCall.Web\Controllers\CallCenterController.cs:line 68
   at ClickToCall.Web.Controllers.CallCenterController.GetUri(String salesNumber) in C:\Users\Rhodes\Documents\Visual Studio 2017\Projects\clicktocall-csharp-master\ClickToCall.Web\Controllers\CallCenterController.cs:line 54
   at ClickToCall.Web.Controllers.CallCenterController.<Call>d__5.MoveNext() in C:\Users\Rhodes\Documents\Visual Studio 2017\Projects\clicktocall-csharp-master\ClickToCall.Web\Controllers\CallCenterController.cs:line 46
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass37.<BeginInvokeAsynchronousActionMethod>b__36(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<>c__DisplayClass2b.<BeginInvokeAction>b__1c()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult)
   at System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
   at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)
   at System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
   at System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult)
   at System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult)
   at System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
   at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
   at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)



Request information: 
    Request URL: http://localhost:1430/CallCenter/Call 
    Request path: /CallCenter/Call 
    User host address: ::1 
    User:  
    Is authenticated: False 
    Authentication Type:  
    Thread account name: DEV-103\Rhodes 

Thread information: 
    Thread ID: 8 
    Thread account name: DEV-103\Rhodes 
    Is impersonating: False 
    Stack trace:    at ClickToCall.Web.Controllers.CallCenterController.<>c__DisplayClass7_0.<IsProduction>b__0(String domain) in C:\Users\Rhodes\Documents\Visual Studio 2017\Projects\clicktocall-csharp-master\ClickToCall.Web\Controllers\CallCenterController.cs:line 68
   at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate)
   at ClickToCall.Web.Controllers.CallCenterController.IsProduction() in C:\Users\Rhodes\Documents\Visual Studio 2017\Projects\clicktocall-csharp-master\ClickToCall.Web\Controllers\CallCenterController.cs:line 68
   at ClickToCall.Web.Controllers.CallCenterController.GetUri(String salesNumber) in C:\Users\Rhodes\Documents\Visual Studio 2017\Projects\clicktocall-csharp-master\ClickToCall.Web\Controllers\CallCenterController.cs:line 54
   at ClickToCall.Web.Controllers.CallCenterController.<Call>d__5.MoveNext() in C:\Users\Rhodes\Documents\Visual Studio 2017\Projects\clicktocall-csharp-master\ClickToCall.Web\Controllers\CallCenterController.cs:line 46
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass37.<BeginInvokeAsynchronousActionMethod>b__36(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<>c__DisplayClass2b.<BeginInvokeAction>b__1c()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult)
   at System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
   at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)
   at System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
   at System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult)
   at System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult)
   at System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
   at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
   at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Ngrok隧道运行:

full setup

1 个答案:

答案 0 :(得分:1)

Rody,我是Twilio开发人员教育工作者,我们专门研究文档和那些教程。

您帮我们发现了解决方案中的错误!我们假设Origin标头将被传递,但显然是FireFox doesn't send it for AJAX requests。我们已经调整了解决方案以寻找&#34; PublicUrl&#34; AppSetting,以便应用知道您的应用在哪里公开托管,并可以将正确的URL发送到Twilio。

下拉最新版本的存储库并更新您的ClickToCall.Web\Local.config以包含&#34; PublicUrl&#34;使用您的ngrok URL设置(没有尾部斜杠)。我在自述文件中记录了这一点,ClickToCall.Web\Local.config.example中有一个示例。

其他人可能出现此问题的另一个可能原因是,如果您在本地运行但使用&#34; localhost&#34;而不是ngrok。简而言之,您需要做的就是:

选项1 :命令行

  1. 下载并安装ngrok
  2. 运行此命令以启动隧道: ngrok http 1430 -host-header="localhost:1430"
  3. 这将创建一个独特的ngrok网址,类似于:8da2afef.ngrok.io
  4. 从Visual Studio运行应用程序,以便它正在聆听。
  5. 在浏览器中打开该ngrok网址并测试该应用。
  6. 选项2 :Visual Studio扩展程序

    1. 下载并安装ngrok Extensions
    2. 在Visual Studio中,打开ClickToCall解决方案,选择&#34;工具&#34;菜单并选择&#34;启动ngrok隧道&#34;
    3. 这将创建一个独特的ngrok网址,类似于:8da2afef.ngrok.io
    4. 从Visual Studio运行应用程序,以便它正在聆听。
    5. 在浏览器中打开该ngrok网址并测试该应用。
    6. 请接受我们对令人困惑的文件表示歉意。