My ajax Code

My Action Method





My Console Response
Notice** My log didn't Printed
And The data retuened to the ajax
My ajax Code

My Action Method





My Console Response
Notice** My log didn't Printed
And The data retuened to the ajax
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.
Set a breakpoint at top of your action method.
Start the debugger.
Navigate in your app until the action method is called.
Step through your code.
When exception occurs the debugger will tell you exactly what is wrong and where it failed.
Provide all that information so somebody can help you if you are unable to figure it out on your own.

i did all that steps
and This is the last statement in my c# code that returned to view
and everything seems right to me
You're using LINQ which uses deferred execution. Put a call to ToArray to force the execution of the query before it gets returned to the runtime.
var data = ...
//Will likely fail here and give you the exception
var results = data.ToArray();
return Json(results);
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
3 people are following this question.