The Twilio examples used named parameters, which your code doesn’t, so probably you have them in the wrong order.
Sending SMS from ASP.NET Web Application Using Twilio API

I am attempting to implement a feature that allows a user to send an SMS to a mobile number from a web application using the Twilio API.
The application setup consists of two text boxes:
DestnationPhone.Text
SmsMessage.Text
In this feature, a user will enter the mobile phone number in the DestnationPhone
text box and the message in the SmsMessage
text box. After this, the user will click the send button to send the message to the recipient's mobile number.
I would like guidance on how to achieve this using the Twilio API. Below is the code I have attempted, but I am encountering errors on two lines, and I am unsure if it is correct.
Please see the code snippet in the image below for reference:
Can someone provide assistance on how to properly implement this feature?
Developer technologies C#
2 answers
Sort by: Most helpful
-
Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
2025-05-12T15:28:13.76+00:00 -
P a u l 10,761 Reputation points
2025-05-12T18:29:44.4133333+00:00 Like Bruce said you need to specify the names of the parameters for
MessageResource.Create
calls as there are a lot of parameters accepted by this call & they're not in the same order as your example, i.e.:Here's an example (note the
to:
,from:
body:
andclient:
before each value, making it unambiguous):// Now that we have our custom built TwilioRestClient, // we can pass it to any REST API resource action. var message = MessageResource.Create( to: new PhoneNumber("+15017122661"), from: new PhoneNumber("+15017122661"), body: "Hey there!", // Here's where you inject the custom client client: twilioRestClient );
Lifted this example from here: https://github.com/twilio/twilio-csharp/blob/HEAD/advanced-examples/custom-http-client.md