Asp.net mvc TwiML应用程序意外结束调用:找不到元素';答复';

Asp.net mvc TwiML应用程序意外结束调用:找不到元素';答复';,asp.net-mvc,twilio,Asp.net Mvc,Twilio,我创建了应用程序并将语音请求URL设置为web部署的ASP.NET-MVC应用程序操作方法: 当有人转到上面发布的URL时,将调用此操作方法: public ActionResult Voice() { Response.ContentType = "text/xml"; // put a phone number you've verified with Twilio to use as a caller ID number

我创建了应用程序并将语音请求URL设置为web部署的ASP.NET-MVC应用程序操作方法:

当有人转到上面发布的URL时,将调用此操作方法:

 public ActionResult Voice() {

            Response.ContentType = "text/xml";

            // put a phone number you've verified with Twilio to use as a caller ID number
            string callerId = Settings.TwilioNumber;

            // put your default Twilio Client name here, for when a phone number isn't given
            string number = "jenny";

            // get the phone number from the page request parameters, if given
            if (Request["PhoneNumber"] != null) {
                number = Request["PhoneNumber"];
            }

            // wrap the phone number or client name in the appropriate TwiML verb
            // by checking if the number given has only digits and format symbols
            string numberOrClient;
            var m = Regex.Match(number, @"^[\d\+\-\(\) ]+$");
            if (m.Success) {
                numberOrClient = string.Format("<Number>{0}</Number>", number);
            } else {
                numberOrClient = string.Format("<Client>{0}</Client>", number);
            }
            ViewBag.CallerId = callerId;
            ViewBag.NumberOfClient = numberOrClient;
            return View();
        }
然后我尝试进行测试调用:

但13秒后,呼叫自动终止,在错误日志中我得到:

Notification SID NOe85ffe80dfc52e81f942a7414c9f7c9c
Warning 12200 Schema validation warning
Description Cannot find the declaration of element 'response'.
但在主体部分的下方,我可以看到元素
响应


您好,这里是Twilio开发者福音传道者

您可以尝试修改视图,使其看起来像这样吗

<?xml version="1.0" encoding="UTF-8" ?>
<Response>
    <Dial callerId="@ViewBag.CallerId">
        @Html.Raw(ViewBag.NumberOfClient)
    </Dial>
</Response>

感谢您的努力。正如您所建议的,我已将XML更正为此版本:但现在我得到:模式验证警告
属性“callerid”不允许出现在元素“Dial”中。
我将尝试使用Twiml为我生成XML。嘿,又一次使用了错误的情况。我刚刚更新了我的示例,这样callerId就不全是小写了。在Visual Studio 2013中,我无法安全地将XML粘贴到cshtml中,因为它会自动格式化,从而更改字母大小写(小写)。正如我所看到的,这是一个常见的问题:您能否演示如何使用
Twilio.twiliml实现相同的功能,因为我只能在/www.Twilio上找到原始的XML示例。com@Yoda使用Twiml的生成器更新了答案
<?xml version="1.0" encoding="UTF-8" ?>
<Response>
    <Dial callerId="@ViewBag.CallerId">
        @Html.Raw(ViewBag.NumberOfClient)
    </Dial>
</Response>
var twiml = new TwilioResponse();
var dialAttributes = new {callerId = "48326304351"};

var dial = twiml.Dial("+15555555555", dialAttributes);
return TwiML(dial);