C# post提交数据时后台接收方法

2020-09-14  本文已影响0人  飞天猪Pony
  public ActionResult PushWeatherInfoSecond()
        {
              try
                {
                    HttpContext.Response.ContentType = "application/json";
                    HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache);
                    using (var reader = new System.IO.StreamReader(HttpContext.Request.InputStream))
                    {
                        String data = reader.ReadToEnd();//data是post传过来的数据
                        System.IO.File.AppendAllText(AppDomain.CurrentDomain.BaseDirectory + "/log" + DateTime.Now.ToString("yyyyMMdd") + "type2" + ".log",
                                            DateTime.Now + " data :  " + data + "\r\n");
                        if (!string.IsNullOrEmpty(data))
                        {
                            
                        }
                    }
                    return Json(new { retcode = 10009, text = "参数不能为空", value = "" }, JsonRequestBehavior.AllowGet);
                }
                catch (Exception ex)
                {
                   
                }
        }
上一篇下一篇

猜你喜欢

热点阅读