Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Wrap Results in Web.Api when exceptions occur #3176


User avatar
0
bilalhaidar created

Hi, In the documentation it says:

ASP.NET Boilerplate does not wrap Web API actions by default if the action has successfully executed. But it handles and wraps for exceptions.

In the ResultWrapperHandler.cs inside Web.Api project, I noticed it starts as:

protected virtual void WrapResultIfNeeded(HttpRequestMessage request, HttpResponseMessage response)
        {
            if (!response.IsSuccessStatusCode)
            {
                return;
            }

For this in contradiction to what documentation says unless I am looking at the wrong class.

Appreciate your feedback.

Thanks


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

    Hi,

    This might be a documentation mistake, can you create an issue for aspnetboilerplate repository ?

    Thanks.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @drcgreece,

    As we have checked, it works like expected and it is explained correct in the document. This class is called only for successfull results and the control you metioned is for when developers return error codes directly from webApi.

    Thanks.

  • User Avatar
    0
    bilalhaidar created

    According to what you said: This class is called only for successful results and...

    And given the documentation: ASP.NET Boilerplate does not wrap Web API actions by default if the action has successfully executed. But it handles and wraps for exceptions.

    There is still something missing.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    The documentation refers to this class <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/master/src/Abp.Web.Api/WebApi/ExceptionHandling/AbpApiExceptionFilterAttribute.cs">https://github.com/aspnetboilerplate/as ... tribute.cs</a>.

    Thanks.

  • User Avatar
    0
    bilalhaidar created

    On this page: <a class="postlink" href="https://aspnetboilerplate.com/Pages/Documents/Web-API-Controllers">https://aspnetboilerplate.com/Pages/Doc ... ontrollers</a>

    Check the wrapping section towards the end of the page.

    And then, this class below, when is it used then?

    protected virtual void WrapResultIfNeeded(HttpRequestMessage request, HttpResponseMessage response)
            {
                if (!response.IsSuccessStatusCode)
                {
                    return;
                }
    
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @drcgreece,

    I understand your approach but as you can imagine we cannot explain every part of framework :). You can download ABP's source code and investigate it by yourself, if it does not work as expected, you can request help for that.

    Why did you need that much deep information while using AspNet Zero ?

  • User Avatar
    0
    bilalhaidar created

    No problem. I need such detail as to understand how things run and that way I can debug issues more. Thanks