using Newtonsoft.Json; using Microsoft.Extensions.DependencyInjection; namespace EVCB_OCPP.DBAPI; public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } public void ConfigureServices(IServiceCollection services) { JsonConvert.DefaultSettings = () => new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore, DateFormatString = "yyyy-MM-dd'T'HH':'mm':'ss'Z'" }; services.AddControllersWithViews() .AddControllersAsServices() // Newtonsoft.Json is added for compatibility reasons // The recommended approach is to use System.Text.Json for serialization // Visit the following link for more guidance about moving away from Newtonsoft.Json to System.Text.Json // https://docs.microsoft.com/dotnet/standard/serialization/system-text-json-migrate-from-newtonsoft-how-to .AddNewtonsoftJson(options => { options.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore; options.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.None; options.SerializerSettings.DateFormatString = "yyyy/MM/dd'T'HH':'mm':'ss'Z'"; options.UseMemberCasing(); }); } public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseRouting(); //app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); }); } }