Prasenjit  Dey

Prasenjit Dey

  • 1.9k
  • 251
  • 43.8k

Code for send sms is not working

Feb 23 2015 4:45 AM
I have used below code for send sms.
 in aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="sms.aspx.cs" Inherits="sms.sms" %>
<!DOCTYPE html>
<html xmlns="">
<head id="Head1" runat="server">
<title>Send Sms</title>
<form id="form1" runat="server">
<asp:Label ID="Label1" runat="server" Text="Mobile No"></asp:Label> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<asp:Label ID="Label2" runat="server" Text="Message"></asp:Label>
<asp:TextBox ID="TextBox2" runat="server" TextMode="MultiLine"></asp:TextBox>
<br />
<asp:Button ID="Button1" runat="server" Text="Send Sms"
onclick="Button1_Click" />
And in .cs page:
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Net;
namespace sms
public partial class sms : System.Web.UI.Page
string uid;
string password;
string message;
string no;
protected void Page_Load(object sender, EventArgs e)
protected void Button1_Click(object sender, EventArgs e)
uid = "9836599564";
password = "8119fc";
message = TextBox2.Text;
no = TextBox1.Text;
TextBox2.Text = "";
TextBox1.Text = "";
catch (Exception ex)
//This is the code of API for sending message.
public void send()
HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create("" + 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();
But after running the above code it shows an error, error is
The remote server returned an error: (403) Forbidden. 
As far I know, this error shows, if an unauthenticated user tries to enter into the webservice. But I have create a account in and just put the details in the uid and pwd. I don't know, what is reason behind this error. So please anyone can help me. 

Answers (1)