locked
Blazor Server with HTTP POST 2X "500 internal server error" - yet new records in db? RRS feed

  • Question

  • User379720387 posted

    Data returned from a form is newService.

    In the AddService() method I create and populate the Service and Provider Service Entities which are related.

    There are two HTTP Post attempts that succeed as far as new records in the tables, however  response.Result and response1.Result  both have the IsSuccessStatusCode flag set to FALSE and each report Internal Server Error.

    No further clues are offered what is the problem.

    Model.Service:

    {BtApiEf5.Model.Service}
        IsProcedure: false
        Maincat: "Add On"
        Note: null
        Package: null
        ProviderServices: Count = 0
        Role: null
        RoleId: 8
        ServiceId: 0
        ServiceName: "test no. 3"
        ShortForm: "test no. 3"
        Size: null
        Strength: null
        Subcat: null
    

    Model.ProviderService:

    {BtApiEf5.Model.ProviderService}
        BillingBasis: "each"
        BillingRate: 20.00
        Id: 0
        NegotiatedProviderServices: Count = 0
        Provider: null
        ProviderId: 22
        ProviderRxTransactions: Count = 0
        ProviderSvcTransactions: Count = 0
        Service: null
        ServiceId: 250
        ServiceLevel: null
        ServiceLevelId: 1
        ToShow: true
    

    Why the internal server errors if the HTTP Post complete?

    And, note the highlighted 250 which is the hard coded ServiceId, what is the mechanism to get that returned as part of <response>?

    Tuesday, March 2, 2021 3:31 AM

Answers

  • User1120430333 posted

    The HTTP 500 means that the code running on the Web server through an exception. The exception was swallowed by  the Web server that through the HTTP 500, because there was no exception handling to catch and log the exception for review, which happened after the save of data.

    How to Catch All Exceptions in C# & Find All Application Errors – Stackify

    The WebAPI project in the on the GitHub solution implements the ErrorHandlingFilter class that catches all unhandled exception there are no try/catch in the WebAPI or the DAL code it references the error filter code catches the exception.

    The corrected link is now given.

    darnold924/PubCompanyCore3.x (github.com)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, March 2, 2021 11:11 PM