I have a .Net Core MVC 3.1 Web Application where i have to upload a file, and i want that file to be with a max size of 100MB. I'm trying to display an error using the app.UseExceptionHandler, but it doesn't work. I even used a custom middleware to try to see where the request goes and it doesn't go there.
Startup.cs
//app.UseExceptionHandler("/Errores"); <-- Tryed this and all the ways with useStatusCode...
//if (env.IsDevelopment())
//{
// app.UseDeveloperExceptionPage();
//}
//else
//{
// // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
// app.UseHsts();
//}
app.Use(async (context, next) =>
{
//try
//{
await next(); <-- It doesn't even reach here
//}
//catch { }
if (context.Response.StatusCode == 413)
{
context.Request.Path = "/Error/404";
await next();
}
});
app.UseHttpsRedirection();
app.UseFileServer();
app.UseCookiePolicy();
app.UseRouting();
app.UseSession();
app.UseAuthentication();
// Add MVC to the request pipeline.
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Login}/{action=Index}/{id?}");
endpoints.MapControllerRoute(
name: "Errores",
pattern: "Errores/{action}",
defaults: new { controller = "Errores" });
});
The controller is like this
public ActionResult PostAyuda([FromForm] AyudaRequest dataRequest)
{
Any help?