0
digitalcontrol created
AddJsonOptions method in Startup.cs doesn't work. We tried a few options but none of them worked. How can we set SerializerSettings.DateFormatString?
First option:
services.AddMvc(options =>
{
options.Filters.Add(new CorsAuthorizationFilterFactory(DefaultCorsPolicyName));
}).SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
.AddJsonOptions(options =>
{
options.SerializerSettings.DateFormatString = "dd-MMM-yyyy";
});
Second option from link https://github.com/aspnetboilerplate/aspnetboilerplate/issues/2764 :
services.PostConfigure<MvcJsonOptions>(options =>
{
foreach (var convert in options.SerializerSettings.Converters)
{
if (convert is AbpDateTimeConverter)
{
var tmpConverter = convert as AbpDateTimeConverter;
tmpConverter.DateTimeFormat = "dd-MMM-yyyy";
}
}
});
return services.AddAbp<RIMIKSXWebHostModule>(options =>
{
...
});
Third option:
services.Configure<MvcJsonOptions>(options => { options.SerializerSettings.DateFormatString = "dd-MMM-yyyy"; });
return services.AddAbp<RIMIKSXWebHostModule>(options =>
{
...
});
2 Answer(s)
-
0
Application Services as Controllers
To use Mvc datetime format options, you can set this property
Configuration.Modules.AbpAspNetCore().UseMvcDateTimeFormatForAppServices
. Its default value isfalse
. -
0
It works! Thank you.