Sending SMS from an ASP.NET website

Is there a way to send SMS from an ASP.NET website using a Web API? I know about web services, but don't know how to call those services from my app.


Web services are the best way to do it. I use Twilio on a site, and it was incredibly easy to get set up and working. Scalability is no issue, and you will more than make up for the cost in not having to spend developer hours building your own solution.


Twilio libraries available for .NET:

From the twilio-csharp project, here is the example of how to send an SMS (I took this from twilio-csharp. Just reposting it to show how easy it is)

static void Main(string[] args)
    TwilioRestClient client;

    // ACCOUNT_SID and ACCOUNT_TOKEN are from your Twilio account
    client = new TwilioRestClient(ACCOUNT_SID, ACCOUNT_TOKEN);

    var result = client.SendMessage(CALLER_ID, "PHONE NUMBER TO SEND TO", "The answer is 42");
    if (result.RestException != null) {

I think I am a bit late to tell you that you are in luck, but for those who find this article later, I created a video showing how to send a Text Message using your Twilio account and

i walk you through sending a text message using twilio and c#

In case you don't have 10 minutes to spend watching the video, here is the code:

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Configuration;
using Twilio;

namespace TwilioSMSHowTo
    public partial class _default : System.Web.UI.Page
        protected void Page_Load(object sender, EventArgs e)

        protected void SendMessage_OnClick(object sender, EventArgs e)
            string ACCOUNT_SID = ConfigurationManager.AppSettings["ACCOUNT_SID"];
            string AUTH_TOKEN = ConfigurationManager.AppSettings["AUTH_TOKEN"];

            TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);

            client.SendMessage("(502) 276-8990", ToNumber.Text, Message.Text);

To make this code work you need to nuGet the Twilio API and need to replace the my configurationmanager.appsettings stuff with your account id and auth token.

Happy coding!

Instead of doing it with Twilio API, if you prefer to do it with another SMS service provider I think below code will help you:

public void sendsms(object sender, EventArgs e)

    if (Page.IsValid)
        HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create("" + yourmobilenumber + "&pwd=" + yourpassword + "&msg=" + body.Text + "&phone=" + recipientNo.Text + "&provider=way2sms");
        HttpWebResponse myResp = (HttpWebResponse)myReq.GetResponse();
        System.IO.StreamReader respStreamReader = new System.IO.StreamReader(myResp.GetResponseStream());
        string responseString = respStreamReader.ReadToEnd();


Need Your Help

Getting Device ID or Mac Address in iOS

ios objective-c device mac-address

I have an application that uses rest to communicate to a server, i would like to obtain the iphones either mac address or device ID for uniqueness validation, how can this be done?