Base solution for your next web application
Open Closed

Getting error 500 due to content-type #12040


User avatar
0
Ricavir created

Hi,

I'm using ABP ZERO (abp 8.2.0) with Angular 15 (abp-web-resources ^5.7.0). For some reason, I'm getting an Internal Server Error on some POST requests . The error is :

POST https://mywebsite.com/api/services/app/QuoteType/CreateOrUpdateQuoteType   500 (Internal Server Error)
WARN:
Content-Type is not sent!

Right now, this is occuring only on Chrome browsers. If I wait 5 or 10 minutes, the same request is sent correctly (wihtout doing anything else).

When the problem occurs, If I switch to a different brower (let say Edge), the problem do not occur for the same request. We noticed that this can happen in one specific POST request or, sometimes, to all requests.

Should be then an issue on client side.

Can you please provide some help to resolve this ?


6 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @Ricavir

    If you are getting a 500 response, there must be a detailed error log on server side. Could you check the logs and share related error message ?

  • User Avatar
    0
    Ricavir created

    Hi @Ismcagdas,

    No we don't have any error message logged in server side. This seems to be linked with Chrome browsers. The same exact request sent with edge or Firefox is working fine. Here is the message displayed :

    It is not something we can reproduce easily, it only happens for some users. We noticed only on Chrome with Windows 11.

    In Kudu detailed logs, I found this :

    Any idea ?

    We really have to fix this as it is impacting several users right now. Tks

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @Ricavir

    Is it possible for us to test this on your live app ? If so, please send an email to [email protected].

    Thanks,

  • User Avatar
    0
    Ricavir created

    Hi @ismcagdas,

    Sure, I've just sent you an email.

  • User Avatar
    0
    Ricavir created

    @ismcagdas, I have more information, the error reported on server side is :

    StatusCode cannot be set because the response has already started

    here are the server logs :

    WARN  2024-06-07 13:57:50,467 [110  ] e.Diagnostics.ExceptionHandlerMiddleware - The response has already started, the error handler will not be executed.
    ERROR 2024-06-07 13:57:50,468 [110  ] AspNetCore.Server.IIS.Core.IISHttpServer - Connection ID "11024811889413598794", Request ID "80002efa-0000-9900-b63f-84710c7967bb": An unhandled exception was thrown by the application.
    System.InvalidOperationException: StatusCode cannot be set because the response has already started.
       at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContext.ThrowResponseAlreadyStartedException(String name)
       at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContext.Microsoft.AspNetCore.Http.Features.IHttpResponseFeature.set_StatusCode(Int32 value)
       at Abp.AspNetCore.Mvc.ExceptionHandling.AbpExceptionFilter.HandleAndWrapException(ExceptionContext context, WrapResultAttribute wrapResultAttribute)
       at Abp.AspNetCore.Mvc.ExceptionHandling.AbpExceptionFilter.OnException(ExceptionContext context)
       at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
       at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
       at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
       at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
       at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
       at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
       at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
       at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
       at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
       at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
       at Abp.AspNetZeroCore.Web.Authentication.JwtBearer.JwtTokenMiddleware.<>c__DisplayClass0_0.<<UseJwtTokenMiddleware>b__0>d.MoveNext()
    --- End of stack trace from previous location ---
       at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
       at MyApp.Web.Startup.Startup.<>c.<<Configure>b__5_1>d.MoveNext() in D:\a\1\s\aspnet-core\src\MyApp.Web.Host\Startup\Startup.cs:line 193
    --- End of stack trace from previous location ---
       at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.<Invoke>g__Awaited|8_0(ExceptionHandlerMiddlewareImpl middleware, HttpContext context, Task task)
       at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.HandleException(HttpContext context, ExceptionDispatchInfo edi)
       at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.<Invoke>g__Awaited|8_0(ExceptionHandlerMiddlewareImpl middleware, HttpContext context, Task task)
       at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
       at Abp.AspNetCore.Security.AbpSecurityHeadersMiddleware.Invoke(HttpContext httpContext)
       at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContextOfT`1.ProcessRequestAsync()
    

    The problem is occuring in the startup.cs file, here is the code line :

    app.Use(async (context, next) => { await next(); if (context.Response.StatusCode == 404 && !Path.HasExtension(context.Request.Path.Value)) { context.Request.Path = "/index.html"; await next(); } });

    Only POST requests are firing this exception ; If the user waits for 5/10 min, the problem disappears. Seems to be linked with JwtTokenMiddleware... maybe with a worker in charge of jwt tokens

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @Ricavir

    We can continue via email for this issue.