问题描述
System.dll中出现'System.Net.WebException'类型的异常,但未在用户代码中处理
附加信息:a期间发生异常WebClient请求。
我尝试过:
公共字符串sendSMS ()
{
string titile = ddlTitle.SelectedItem.Text;
txtmsg.Text =Welcome+ titile ++ txtName .Text +to Wellness Solutions Pvt Ltd!。\ n您的患者ID是:+ PatientID.Text +。\ n登录详情:\ n分支:+ branch_name +\ n用户名:+ PatientID.Text +\ n密码:+ password.ToString()+;
String message = HttpUtility.UrlEncode(txtmsg.Text);
using (var wb = new WebClient())
{
byte [] response = wb.UploadValues(https://api.textlocal.in/send/, new NameValueCollection()
{
{username,[email protected]},
{hash,2d4666b1584a17da83c44673218b2229c9f7bcdb},
{ numbers,txtMobile.Text},
{message,message},
{sender,TXTLCL},
});
string result = System.Text.Encoding.UTF8.GetString(response);
返回结果;
}
}
An exception of type 'System.Net.WebException' occurred in System.dll but was not handled in user code
Additional information: An exception occurred during a WebClient request.
What I have tried:
public string sendSMS()
{
string titile = ddlTitle.SelectedItem.Text;
txtmsg.Text = "Welcome " + titile + " " + txtName.Text + " to Wellness Solutions Pvt Ltd !. \n Your Patient ID is: " + PatientID.Text + ".\n Login Details:\n Branch: " + branch_name + "\n username: " + PatientID.Text + "\n password :" + password.ToString() + "";
String message = HttpUtility.UrlEncode(txtmsg.Text);
using (var wb = new WebClient())
{
byte[] response = wb.UploadValues("https://api.textlocal.in/send/", new NameValueCollection()
{
{"username" , "[email protected]"},
{"hash" , "2d4666b1584a17da83c44673218b2229c9f7bcdb"},
{"numbers" , txtMobile.Text},
{"message" , message},
{"sender" , "TXTLCL"},
});
string result = System.Text.Encoding.UTF8.GetString(response);
return result;
}
}
推荐答案
这篇关于如何解决webclient请求期间发生的异常。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!