Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
1.80/5 (2 votes)
See more:
Hello,

I am using this code for send sms but its getting error:-

XML
SMS.APIType = SMSGateway.Site2SMS;
        SMS.MashapeKey = "<xxxx>";
        SMS.Username = txtNumber.Text.Trim();
        SMS.Password = txtPassword.Text.Trim();
        if (txtRecipientNumber.Text.Trim().IndexOf(",") == -1)
        {
            //Single SMS
            SMS.SendSms(txtRecipientNumber.Text.Trim(), txtMessage.Text.Trim());
        }
        else
        {
            //Multiple SMS
            List<string> numbers = txtRecipientNumber.Text.Trim().Split(',').ToList();
            SMS.SendSms(numbers, txtMessage.Text.Trim());
        }


Error:-
The remote server returned an error: (403) Forbidden.


I am trying one more code also but its getting error:-

C#
protected void Button1_Click(object sender, EventArgs e)
{
    try
    {
        uid = "xxxxxxxxxx";
        password = "xxxxx";
        message = TextBox2.Text;
        no = TextBox1.Text;
        send();
        TextBox2.Text = "";
        TextBox1.Text = "";
    }
    catch (Exception ex)
    {
        ex.Message.ToString();
    }
}
public void send()
{
    HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create("http://ubaid.tk/sms/sms.aspx?uid=" + uid + "&pwd=" + password + "&msg=" + message + "&phone=" + no + "&provider=fullonsms");
    HttpWebResponse myResp = (HttpWebResponse)myReq.GetResponse();
    System.IO.StreamReader respStreamReader = new System.IO.StreamReader(myResp.GetResponseStream());
    string responseString = respStreamReader.ReadToEnd();
    respStreamReader.Close();
    myResp.Close();
}

Please help me,
How can we send sms using c# asp.net?

Thanks in Advance.

Ankit Agarwal
Website Developer
Posted
Updated 18-Jul-14 2:18am
v3
Comments
ZurdoDev 18-Jul-14 7:19am    
I believe that error means you username/password or something not in the code is incorrect.
[no name] 18-Jul-14 7:28am    
username and password is correct.

Hello,
my first guess is, that the web server might check the request's User Agent.
So try something like this:
C#
HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create("http://ubaid.tk/sms/sms.aspx?uid=" + uid + "&pwd=" + password + "&msg=" + message + "&phone=" + no + "&provider=fullonsms");
            //see for other choices: http://www.useragentstring.com/pages/useragentstring.php
            myReq.UserAgent = "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2049.0 Safari/537.36";
            HttpWebResponse myResp ...


On the other hand, I've just tried to check this website (I didn't know about it) and it says it's under maintenance, so maybe that's the real cause.
 
Share this answer
 
register MashapeKey website and copy the Key from MashapeKey paste to
SMS.MashapeKey = "<xxxx>" your key xxxx and then run your code
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900