ASP.NET MVC源码分析系列
2015-08-01 17:59
676 查看
Controller下的JsonResult的ExecuteResult方法
此处使用的JavaScriptSerializer进行的序列化
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(MvcResources.JsonRequest_GetNotAllowed); } 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) { JavaScriptSerializer serializer = new JavaScriptSerializer(); if (this.MaxJsonLength.HasValue) { serializer.MaxJsonLength = this.MaxJsonLength.Value; } if (this.RecursionLimit.HasValue) { serializer.RecursionLimit = this.RecursionLimit.Value; } response.Write(serializer.Serialize(this.Data)); } }
此处使用的JavaScriptSerializer进行的序列化
相关文章推荐
- asp.net+swfupload 多图片批量上传(附源码下载)
- ASP.NET 5探险(6):升级ASP.NET 5到beta6
- ASP.NET 5 Beta6发布了(翻译)
- 【ASP.NET】——AdRotator控件
- ASP.NET MsChart 控件出错:为 ChartImg.axd 执行子请求时出错
- ASP.NET Web API 特性
- asp.net MVC 模拟实现与源码分析
- ASP.NET MVC 小牛之旅1:何谓MVC
- Aspose.Words组件介绍及使用—基本介绍与DOM概述
- 搭建jasperserver报表服务器
- CASpringAnimation
- Visual C#中的winform/webform/asp.net控件命名规范
- ASP.NET的简单认识
- 判断填写的邮箱里是否有“@”
- Asp.net中全局缓存的几种方式
- ASP.Net抓取页面
- Asp.Net 请求处理机制
- asp.net发送邮件
- ASP.Net与存储过程
- *.ascx *.asax *.aspx.resx *.asax.resx是什么文件