proudmonkey / AutoWrapper

A simple, yet customizable global exception handler and Http response wrapper for ASP.NET Core APIs.
MIT License
677 stars 82 forks source link

Why 400 can't display status code #128

Open apchenjun opened 2 years ago

apchenjun commented 2 years ago

Why 400 can't display status code

{
    "isError": true,
    "error": {
        "message": "Request invalid.",
        "code": "BadRequest"
    }
}

I want to always show status code like 200

{
    "statusCode": 200,
    "message": "POST Request successful.",
    "result": {
        "totalCount": 0,
        "items": []
    }
}
proudmonkey commented 2 years ago

Have you set ShowStatusCode option?

apchenjun commented 2 years ago

@proudmonkey yes I have set that no status code is returned when the status code 400 is returned in the 200 status 。

    app.UseAutoWrapper(new AutoWrapperOptions
    {
        ShowStatusCode = true,
        IsDebug = !app.Environment.IsProduction(),
        ShowIsErrorFlagForSuccessfulResponse = true,
        DisableProblemDetailsException = true
    });
proudmonkey commented 2 years ago

Which version you are using for me to reproduce?

apchenjun commented 2 years ago

@proudmonkey image

apchenjun commented 2 years ago

@proudmonkey Is it possible to reproduce and fix the problem

proudmonkey commented 2 years ago

@apchenjun My apologies for the late response. Just got so busy with so many things. :)

I will try to reproduce the issue using the latest version and provide a fix. I'll keep this thread posted. Thank you so much for your feedback. :)

apchenjun commented 2 years ago

@proudmonkey I am using .Net Core 6.0