How to use with top-lavel statements #15
-
Hi, My var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRazorPages();
var app = builder.Build();
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
// **********
// TODO: I want to be able to serialize DateOnly in my API endpoints requests/responses
endpoints.MapControllers(); // Map attribute-routed API controllers
// **********
endpoints.MapRazorPages();// Map razor pages
});
app.Run(); Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi, does this work? After that var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRazorPages();
builder.Services
.AddControllers(options => options.UseDateOnlyTimeOnlyStringConverters())
.AddJsonOptions(options => options.UseDateOnlyTimeOnlyStringConverters());
var app = builder.Build();
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers(); // Map attribute-routed API controllers
endpoints.MapRazorPages();// Map razor pages
});
app.Run(); |
Beta Was this translation helpful? Give feedback.
Hi, does this work? After that
DateOnly/TimeOnly
conversions should work for everything (not only controllers)