In my controller I am returning an object of a class with ShouldSerialize{PropertyName}() methods in it but it looks like these methods are not called when MVC action methods are invoked. I even tried returning 'false' as you see commented out in the code below with no luck.
public Department Department { get; set; }
public bool ShouldSerializeDepartment()
{
return Department != null;
// return false;
}
That means, Asp.Net MVC does not call JsonConvert.SerializeObject behind the scenes otherwise conditional serialization would be effective (Am I right?).
Does anyone know how to get it to work?