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 the request successfully, but return 404 after antoAwrapper. #90

Closed skywalkeryin closed 3 years ago

skywalkeryin commented 3 years ago

Hi author, I request a get api, the data can get from database, but it will return 404 after autoWrapper. If I add [AutoWrapIgnore] to get method, then no 404 anymore, reponse is 200.

[HasPermission(Permissions.GET_QUOTATION)] [HttpGet] //[AutoWrapIgnore] public async Task<ApiResponse> Get([FromQuery] string guid) { Quotation quotation = await _quotationService.GetQuotationWithItems(guid); var quotationResponseDTO = _mapper.Map<Quotation, QuotationResponseDTO>(quotation); // over here quotationResponseDTO had value return new Success(quotationResponseDTO); }

proudmonkey commented 3 years ago

Hello,

What's the path of your APIs?

proudmonkey commented 3 years ago

Closed as there's no response.

jjchiw commented 3 years ago

Hi, I had the same problem... I was returning a string with html and it seems autowrapper changed the status 200 to 404....

The solution was to add BypassHTMLValidation

Christian-Sibo-ONRR commented 3 years ago

This really threw me off for several hours as I tried to debug why one endpoint stopped working with a 404 (not found) despite returning all the data in the exception message.

Maybe this should be changed to a 500 or something with a real error message, rather than the original response body.

scil commented 2 years ago

Hi, I had the same problem... I was returning a string with html and it seems autowrapper changed the status 200 to 404....

The solution was to add BypassHTMLValidation

I also send html code string and get 404 ,and the wanted data in the exceptionMessage


{
  "isError": true,
  "responseException": {
    "exceptionMessage": {

      "commentList": [
        {
          "id": 19,
          "createdUser": "4k2n1gmr4zt5w03t0xg075p4wn"
        }
      ],

      "pagerHtml": "\r\n<ul class=\"pager\"><li class=\"disabled first\"><a>&lt;&lt;</a></li><li class=\"disabled\"><a rel=\"prev\">&lt;</a></li><li class=\"active\"><a href=\"/api/common/comment/Index?AuditStatus=030203&amp;Status=1&amp;page=1\">1</a></li><li><a href=\"/api/common/comment/Index?AuditStatus=030203&amp;Status=1&amp;page=2\" rel=\"next\">2</a></li><li><a href=\"/api/common/comment/Index?AuditStatus=030203&amp;Status=1&amp;page=2\" rel=\"next\">&gt;</a></li><li class=\"last\"><a href=\"/api/common/comment/Index?AuditStatus=030203&amp;Status=1&amp;page=2\">&gt;&gt;</a></li></ul>\r\n"
    }
  }
}