短信到asp.net 3.5 [英] SMS vis asp.net 3.5

查看:67
本文介绍了短信到asp.net 3.5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public void SendpasswordSMS(string mobileno, string number, string username)
    {
        int x = 0;
        mobileno = "91" + mobileno;
        string msg = "Dear " + username + ", PASSWORD is:" + number + ";
        // SMS GATEWAY PROVIDER PATH 
// here i use my gateway.
//string url = "http://.........";

        string url1 = String.Format(url, mobileno);
        ///create Web Request object for the url
        HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url1);
        // get the response from the web request
        HttpWebResponse res = (HttpWebResponse)req.GetResponse();
        // read the response from the WebResponse in to a stram 
        Stream s = res.GetResponseStream();
        StreamReader rdr = new StreamReader(s);
        string result = rdr.ReadLine();
        x++;
        s.Flush();
        s.Close();
    }


当我将其与桌面应用程序一起使用时,此代码可以正常工作,但不适用于ASP.NET应用程序.

之前,这工作正常.
问题出在哪里?

请帮助我.


This code is working fine when I am using it with desktop application but it didn''t work with ASP.NET application.

Earlier this was working fine.
What and where is the problem?

Please help me.

推荐答案

尝试此代码.
Try this code .
string ProxyServer = null;
string ProxyUser = null;
string ProxyPass = null;
string ProxyPort = null;
ProxyServer = "00.00.00.00";
ProxyUser = "abc";
ProxyPass = "xyz";
ProxyPort = "8080";
string url = "http://.........";
WebRequest req = WebRequest.Create(url);
// Get Website Proxy
req.Proxy = WebProxy.GetDefaultProxy();
//req.Proxy = new WebProxy(ProxyServer + ":" + ProxyPort, true);
//req.Proxy.Credentials = new NetworkCredential(ProxyUser, ProxyPass);
req.Proxy.Credentials = CredentialCache.DefaultCredentials;
//req.Proxy.Credentials = new NetworkCredential(ProxyUser, ProxyPass); 
WebResponse resp = req.GetResponse();
// Stream the data
System.IO.StreamReader textReader = new System.IO.StreamReader(resp.GetResponseStream());



更多信息: www.Book4dotnet.com



More Info : www.Book4dotnet.com


关于SPAM消息过滤器可能存在一些问题.您需要与您的提供者联系.他们将能够在这方面为您提供帮助.
There may be some issue regarding SPAM message filter. You need to talk to your provider. They will be able to help you in this regard.


这篇关于短信到asp.net 3.5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆