zoukankan      html  css  js  c++  java
  • bisController

        public class BisController : Controller
        {
            //
            // GET: /Bis/
    
    
            protected string GetJson(object obj)
            {
                IsoDateTimeConverter dtConverter = new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" };
                //http://www.cnblogs.com/litian/p/3870975.html
                return JsonConvert.SerializeObject(obj, dtConverter);
            }
    
            protected new JsonResult Json(object data)
            {
                return new HYJosnResult { Data = data };
            }
    
        }
        //http://www.cnblogs.com/chongsha/archive/2013/04/14/3019990.html
        public class HYJosnResult : JsonResult
        {
            public override void ExecuteResult(ControllerContext context)
            {
                if (context == null)
                {
                    throw new ArgumentNullException("context");
                }
                if ((this.JsonRequestBehavior == JsonRequestBehavior.DenyGet) && string.Equals(context.HttpContext.Request.HttpMethod, "GET", StringComparison.OrdinalIgnoreCase))
                {
                    throw new InvalidOperationException("");
                }
                HttpResponseBase response = context.HttpContext.Response;
                if (!string.IsNullOrEmpty(this.ContentType))
                {
                    response.ContentType = this.ContentType;
                }
                else
                {
                    response.ContentType = "application/json";
                }
                if (this.ContentEncoding != null)
                {
                    response.ContentEncoding = this.ContentEncoding;
                }
                if (this.Data != null)
                {
    
                    IsoDateTimeConverter timeFormat = new IsoDateTimeConverter();
                    timeFormat.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                    response.Write(JsonConvert.SerializeObject(this.Data, Newtonsoft.Json.Formatting.Indented, timeFormat));
    
                }
            }
        }
  • 相关阅读:
    LINQ Practice
    windows下python环境安装
    kafka安装教程
    使用python连接mysql/oracle
    使用百度地图实现地图网格
    单链表反转java代码
    mysql的索引问题分析
    java中String字符串的==解析
    辗转相除法的原理
    myeclipse2014新建maven项目
  • 原文地址:https://www.cnblogs.com/lzhp/p/4103141.html
Copyright © 2011-2022 走看看