Reputation: 1
I'm building an asp.net c# website and using Twilio. I'm working on getting it to answer an incoming call but it's not working, every time I call it says there's an application error.
This is what I have in the .aspx file:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="callTest.aspx.cs" Inherits="callTest" %><?xml version="1.0" encoding="UTF-8" ?>
This is what I have in the aspx.cs file:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Twilio;
using Twilio.TwiML;
public partial class callTest : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
var twiml = new Twilio.TwiML.TwilioResponse();
twiml.Say("Hello Monkey!");
Response.ContentType = "text/xml";
Response.Write(twiml.ToString());
Response.Close();
}
}
If I comment out the c# code above and put the following in the .aspx file, it works fine, do you guys know what I'm doing wrong with my c# code?
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="callTest.aspx.cs" Inherits="callTest" %><?xml version="1.0" encoding="UTF-8" ?>
<Response>
<Say>If you are calling from a house phone, press one.</Say>
<Gather/>
</Response>
Upvotes: 0
Views: 2150
Reputation: 56
The reason Twilio is reporting an application error is because there is no XML returned by your page. And, the reason there is no XML returned by your page is quite simply because of the Response.Close() call. Replace the Response.Close() call with Response.End();. Response.End() sends all currently buffered output to the client, while Response.Close() closes the socket connection to the client.
TL;DR;
Replace
Response.Close();
with
Response.End();
Upvotes: 1
Reputation: 10366
Twilio evangelist here.
Try testing this web page by loading the URL you've set as the Voice URL in a browser. Can you reach it successfully and get the TwiML as you would expect?
Twilio is basically telling you "hey, I tried to request this URL but something between me and you made that fail".
That something could be a firewall, a proxy server, etc.
Hope that helps.
Upvotes: 0