i'am getting status 500 in my asp net core code

khamis safy 1 Reputation point
2021-06-01T17:36:53.12+00:00

My ajax Code

101400-1-ajax.png

My Action Method

101424-1-code1.png

101443-1-code2.png101438-1-code3.png101425-1-codeconsole.png101444-1-data.png

My Console Response
Notice** My log didn't Printed

And The data retuened to the ajax

Developer technologies ASP.NET ASP.NET Core
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Michael Taylor 60,161 Reputation points
    2021-06-01T18:12:24.033+00:00

    500 indicates a server side error so the problem is in your C# code. This is where standard debugging comes into play as we have no way of debugging your really, really long query to figure out what is wrong.

    1. Set a breakpoint at top of your action method.
    2. Start the debugger.
    3. Navigate in your app until the action method is called.
    4. Step through your code.
    5. When exception occurs the debugger will tell you exactly what is wrong and where it failed.
    6. Provide all that information so somebody can help you if you are unable to figure it out on your own.

  2. Duane Arnold 3,216 Reputation points
    2021-06-02T07:17:26.063+00:00

    @khamis safy

    A HTTP 500 means a .NET exception was thrown, and it was unhandled by the .NET code. So the Web server IIS swallowed the exception and returned the HTTP 500.

    You should be trying to implement global exception handling in the ASP.NET Core MVC solution to find out what the exception is about by logging the exception and showing a user friendly error page.

    https://stackify.com/csharp-catch-all-exceptions/

    The GitHub solution is doing global exception handling that is logging the exception using Serilog in the Core MVC project. No try/catch is in any code, or in any code the MVC project references all exceptions are caught by the global exception handler.

    https://github.com/darnold924/PublishingCompany

    HTH

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.