title: ASP .NET - JsonIgnore does not seem to work
body: <p><strong>Problem</strong></p>
  
  <p>I cannot serialize a object in MVC .Net when returning a json result because of loop references. </p>
  
  <blockquote>
    <p>Self referencing loop detected for type ...</p>
  </blockquote>
  
  <p><em>My entity class:</em></p>
  
  <pre><code>public class Subscriber
  {
    [JsonIgnore]
    public virtual ICollection&lt;Tag&gt; Tags { get; set; }
  }
  </code></pre>
  
  <p><em>In controller:</em></p>
  
  <pre><code>public JsonResult GetSubscribers(GridRequestModel model)
  {
     data = ... get data ..
     JSON(data, JsonRequestBehavior.AllowGet);
  }
  </code></pre>
  
  <p>It seems that the .NET serializer does not seem to take into account JsonIgnore since I still get the error. </p>
  
  <hr>
  
  <p><strong>Attempted Solution</strong></p>
  
  <p>I changed my controller to the following:</p>
  
  <pre><code>public JsonResult GetSubscribers(GridRequestModel model)
  {
     data = ... get data ..
     JsonSerializerSettings jsSettings = new JsonSerializerSettings();
     jsSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
  
     string json = JsonConvert.SerializeObject(data, Formatting.None, jsSettings);
  
     JSON(json, JsonRequestBehavior.AllowGet);
  }
  </code></pre>
  
  <p>This time I get:</p>
  
  <blockquote>
    <p>The RelationshipManager object could not be serialized. This type of
    object cannot be serialized when the RelationshipManager belongs to an
    entity object that does not implement IEntityWithRelationships.</p>
  </blockquote>
  
  <p>Also, not sure if I can return the string directly since I have return type of JsonResult. Would <code>Json(json ... )</code> work?</p>
  
  <p>Any help is appreciated. Thanks!</p>