jsonoptions does not contain a definiton for serializersettings
builder.Services.AddMvc(options =>
{
options.Filters.Add<JsonExceptionFilter>();
options.Filters.Add<RequireHttpsOrCloseAttribute>();
options.Filters.Add<LinkRewritingFilter>();
})
.AddJsonOptions(options =>
{
options.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc;
options.SerializerSettings.DateFormatHandling = DateFormatHandling.IsoDateFormat;
options.SerializerSettings.DateParseHandling = DateParseHandling.DateTimeOffset;
});
CodePudding user response:
.AddNewtonsoftJson(options =>
{
options.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc;
options.SerializerSettings.DateFormatHandling = DateFormatHandling.IsoDateFormat;
options.SerializerSettings.DateParseHandling = DateParseHandling.DateTimeOffset;
});
CodePudding user response:
Need to Add "AddNewtonsoftJson" in statup.cs file
Dll NuGet: Microsoft.AspNetCore.Mvc.NewtonsoftJson
services.AddMvc().AddNewtonsoftJson(o =>
{
o.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
});
This should work.