[C#] MVC(ajax json return) →→→→→进入此内容的聊天室

来自 , 2021-03-28, 写在 C#, 查看 135 次.
URL http://www.code666.cn/view/9a5748a2
  1.        
  2. ///示例一
  3.        [HttpPost]
  4.         public ActionResult SearchEnt()
  5.         {
  6.             UserCheck();
  7.             string jsonStr = "{\"success\":true,\"message\":\"\"}";
  8.             string keyword = Request["data"];
  9.             if (!string.IsNullOrEmpty(keyword))
  10.             {
  11.                 EntinfoDAl EID = new EntinfoDAl();
  12.                 List<EntInfoMation> Entlist = db.EntInfoMation.Where(o => o.EntName.IndexOf(keyword) != -1 || o.OrgNo.IndexOf(keyword) != -1 || o.LicenceNo.IndexOf(keyword) != -1 || o.EntType.IndexOf(keyword) != -1).Take(10).ToList();
  13.                 StringBuilder EfSb = new StringBuilder();
  14.                 foreach (EntInfoMation ef in Entlist)
  15.                 {
  16.                     EfSb.Append("<tr><td><a href='/Entinfo/Details/" + ef.EntID + "'>" + ef.EntName + "</a></td><td>" + ef.OrgNo + "</td><<td>" + ef.LicenceNo + "</td><td>" + ef.EntType + "</td></tr>");
  17.                 }
  18.                 jsonStr = "{\"success\":true,\"message\":\"" + EfSb + "\"}";
  19.             }
  20.             return Content(jsonStr, "text/html;charset=UTF-8");
  21.  
  22.         }
  23.  
  24. //实例2
  25.         public ActionResult GetEntCertSortDicByTSN(string TSName)
  26.         {
  27.             string jsonStr = null;
  28.             if (!string.IsNullOrEmpty(TSName))
  29.             {
  30.                 List<ServicesLayout.ProductServiceReference.EntCertSortDic> list = ServicesLayout.Creater.ProductCreater.EntCertSortDicManager.GetAllEntCertSortDicByQuery("TopSortName=@0", new object[] { TSName }, "", false);
  31.                 jsonStr = JsonConvert.SerializeObject(list);
  32.             }
  33.             return Content(jsonStr, "text/html;charset=UTF-8");
  34.         }
  35.  
  36.  

回复 "MVC(ajax json return)"

这儿你可以回复上面这条便签

captcha