MVC6 JsonConvert setting JsonResult of an action Globally
<p>I have specific Json formatting requirements in my application for example I want specific date formatting and I want null values to be ignored so I put my code in Startup.cs method configure </p>

<pre><code>public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IHttpContextAccessor contextAccessor)
    {

.....
  JsonConvert.DefaultSettings = () =&gt; new JsonSerializerSettings
   {
    DateFormatString = "dd/MM/yyy hh:mm:ss" ,                 
     NullValueHandling = NullValueHandling.Ignore

   };
.....
</code></pre>

<p>}</p>

<p>Here is an example of my action method</p>

<pre><code>[HttpGet("[action]")]
 public ActionResult GetSampleyData()
  {
    var model= new {StartDate=DateTime.Now, Name="test"};             
     return new JsonResult(model);
  }
</code></pre>

<p>But the result is not being in the format I expected. How can I set the json settings Globally sothat all my action methods use it.</p>