Click here to Skip to main content
15,890,947 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey Guys,

i've some strange problem in sending sms to mobile from asp.net

i am using this function and it works great on my PC (Local)

but after i publish the application online it doesn't work.

it doesn't even give me a message to search for it

Notice: i've put try and catch and i am displaying the error message in a label but the error message returns empty.

may be this is a problem with the server but i don't know from where to start solving it

please give me any notifications about this.

this is the code:


C#
private string SendSMS(string To_Sender, string Message_Text)
    {
        string resultMSG = string.Empty;
        try
        {
            string UserName = "myUserName";
            string Password = "myPassword";
            string SmsText = Message_Text;
            string MSISDNs = To_Sender;
            string URL = "mySMS_Provider_URL";
            SmsText = getBigEndianUnicodeText(SmsText);
            string url = string.Format("{0}?username={1}&password={2}&smstext={3}&isCompressed=1", URL, UserName, Password, SmsText);
            ////Create HTTP Request to the URL.
            HttpWebRequest request = HttpWebRequest.Create(url) as HttpWebRequest;
            // the following lines to use POST method. 
            request.Method = "POST";
            request.Headers = new WebHeaderCollection();
            request.Proxy = new WebProxy(URL, true); ;
            request.Headers.Add("SOAPAction", "\"\"");
            request.Method = "POST";
            request.ContentType = "text/xml;charset=UTF-8";
            request.CachePolicy = new
            System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore);
            request.KeepAlive = true;
            // Compress recipients using GZip algorithm.
            byte[] buffer = Compress(MSISDNs);
            //// Get the request stream.
            Stream dataStream = request.GetRequestStream();
            //// Write the data to the request stream.(Add recipients to the request body)
            dataStream.Write(buffer, 0, buffer.Length);
            dataStream.Close();
            HttpWebResponse response = request.GetResponse() as HttpWebResponse;
            ////Read Page Response.
            StreamReader reader = new StreamReader(response.GetResponseStream());
            string resultString = reader.ReadToEnd();
        }
        catch (Exception ex)
        {
            resultMSG = ex.Message + " //// " + ex.InnerException;
        }
        return resultMSG;
    }
Posted

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