我正在为我们的应用程序编写一个SMS函数。没有错误,但它不符合我的期望。 使用数据集,我得到多个移动号码,然后我需要通过messaage到所有这些手机号码。发送Response.Redirect只发送了1条消息
只有11.使用Response.Redirect的消息和其他人不发送。(后第1个消息发送它进入该网页)的编码下方
DataSet DistDs = _distsms.GetAllDistributionList(UnitId, isShot, gameId, animalTypeId);
if(DistDs.Tables[0].Rows.Count > 0)
{
ContactNo = Convert.ToInt32(DistDs.Tables[0].Rows[0]["ContactNumber"]);
foreach (DataRow row in DistDs.Tables[0].Rows)
{
if (row["ContactNumber"].ToString() != "")
{
try
{
Response.Redirect("http://sms.gatewaysite.com/api/mt?msisdn=" + row["ContactNumber"].ToString() +
"&body=" + msgOut + "&sender=" + shortcode +
"&key=ertyertyer&product_id=4563456&operator=" + oppp + "&country=aaaaa");
}
catch(Exception ee)
{
string a = ee.Message;
//continue;
}
}
}
}
部分
请检查出的[Response.Redirect的]描述(http://msdn.microsoft.com/en-us/library/ a8wa7sdt(v = vs.100).aspx)在MSDN - 也许它不是你需要的方法。目前还不清楚你试图通过代码来达到什么目的(它的行为与你编码的行为完全一样)。 –
@AlexeiLevenkov让我们说数据集返回2行然后我拿那2手机号码(msisdn)和使用response.redirect它发送消息到所有这些numbers.But只有1消息发送.. –
Response.Redirect不发送短信或任何它只是立即返回302作为参数的位置。我*不知道*如果您需要使用此调用,但作为您的示例,它的行为是令人信服的。 Mayby你需要从服务器发送请求作为答案建议(使用'WebClient' /'HttpWebRequest')... –