public JsonResult GetPhoneCode(string tel) { string PHONECODE_CACHE = string.Empty; PHONECODE_CACHE = string.Format("PHONECODE_CACHE_{0}", tel); Random random = new Random(); string strCode = random.Next(100000, 999999) + ""; Session["Phone_Code" + tel] = strCode; if (System.Web.HttpContext.Current.Cache[PHONECODE_CACHE] == null)//重复发送验证 { string smsContent = System.Configuration.ConfigurationManager.AppSettings["yzmContent"]; var sendResult = noticeBll.SendUserCode(tel, strCode); SendsmsLog sendsmsLog = new SendsmsLog(); sendsmsLog.Tel = tel; sendsmsLog.SmsContent = string.Format(smsContent, strCode); sendsmsLog.Sender = "住家帮小秘"; sendsmsLog.SendTime = DateTime.Now; sendsmsLog.SendResult = sendResult; ncBase.CurrentEntities.AddToSendsmsLog(sendsmsLog); ncBase.CurrentEntities.SaveChanges(); System.Web.HttpContext.Current.Cache.Insert(PHONECODE_CACHE, tel, null, DateTime.Now.AddMinutes(2), System.Web.Caching.Cache.NoSlidingExpiration); return(Json(new { status = 0 })); } else { return(Json(new { status = 0 })); } }