.net-coretwiliotwilio-conference

Why is my Twilio conference call responding like a voice call and hanging up?


In my proof of concept code, I am successfully creating a conference call and am able to enter the waiting room and hear the hold music until another participant joins. However, when I move this code into a .NET Core production type solution in visual studio, it responds by reading the Room # and immediately hanging up. I believe it has something to do with .NET Core but have not been able to pinpoint the root cause.

Proof of concept code

using Twilio.TwiML;
using Twilio.AspNet.Mvc;
using System.Web.Mvc;
using Twilio.TwiML.Voice;

namespace MakeAndReceiveCalls.Controllers
{
    public class PhoneController : TwilioController
    {
        [HttpPost]
        public ActionResult MakeConferenceCall()
        {
            var response = new VoiceResponse();
            var dial = new Dial();
            dial.Conference("Room 1234");
            response.Append(dial);

            return Content(response.ToString());
        }
    }
}

Production Code

using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Twilio.AspNet.Core;
using Twilio.TwiML;
using Twilio.TwiML.Voice;

namespace RL.Domain.AudioConference.API.Controllers
{
    [Route("v1/[Controller]")
    public class AudioConferenceController : TwilioController
    {       
        [HttpPost("MakeConferenceCall")]
        public ActionResult MakeConferenceCall()
        {
            var response = new VoiceResponse();
            var dial = new Dial();
            dial.Conference("Room 1234");
            response.Append(dial);

            return Content(response.ToString());
        }
    }
}

Solution

  • Changing the return type from:

    ActionResult
    return Content(response.ToString());
    

    To:

    TwiMLResult
    return TwiML(response);
    

    Fixed the issue. Not sure why the first approach worked in my proof on concept.