. NET MVC Table Primary foreign key relationship JSON Infinite Loop Scheme II (recommended)

Source: Internet
Author: User
Tags httpcontext

   public class Jsonresultobject:jsonresult {private Newtonsoft.Json.JsonSerializerSettings Settings { Get Private set;                } public Jsonresultobject () {Settings = new Newtonsoft.Json.JsonSerializerSettings {referenceloophandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore}             ; 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 Invalidoperatione                Xception ("JSON GET is not allowed"); var response = context.                Httpcontext.response; Response. ContentType = string. IsNullOrEmpty (this. ContentType)? "ApplicatIon/json ": this.                ContentType; if (this. ContentEncoding = null) response. ContentEncoding = this.                ContentEncoding; if (this.                Data = = null) return; var Scriptserializer = Newtonsoft.Json.JsonSerializer.Create (this.                Settings); using (var sw = new StringWriter ()) {scriptserializer.serialize (SW, this).                    Data); Response. Write (SW.                ToString ()); }              }         }

  

. NET MVC Table Primary foreign key relationship JSON Infinite Loop Scheme II (recommended)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.