在.Global.asax.cs 中 增加下面的代码
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
// 解决json序列化时的循环引用问题
GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
//对日期格式进行统一处理
GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.Converters.Add(
new Newtonsoft.Json.Converters.IsoDateTimeConverter()
{
DateTimeFormat = "yyyy-MM-dd hh:mm:ss"
} );
}
}