Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't my ASP.NET Core 2 method return TwiML?

I have an ASP.NET Core 2 application and I'm trying to forward a call made to a Twilio number to another number. When I try to return TwiML I get an error that says:

"Non-invocable member 'TwiML' cannot be used like a method."

Here's the method:

[HttpPost]
public TwiMLResult ForwardCall(string called)
{
   var response = new VoiceResponse();
   response.Dial(newNumber);

   return TwiML(response);
}

The error happens here:

return TwiML(response);

All the code examples I've seen tell me to return the TwiML this way but for some reason, I'm unable to.

like image 253
Ryan Avatar asked Feb 13 '18 18:02

Ryan


1 Answers

The problem was that the controller was not inheriting from TwilioController. Once I had my controller inherit from TwilioController the error went away.

like image 75
Ryan Avatar answered Oct 28 '22 22:10

Ryan