I have a grid table to show all the OptMsgType Record in OptMsgType table by JSON. I can load and delete the table but if I click the "Create" button, it will pop up a blank page ("Create.cshtml"). I check the browser and it shows the error "Failed to load
resource: the server responded with a status of 500 ()" in "Settings/OptMsgType/Create:1". I googled it and it seems kind of server error. I would like to ask if I have way to debug the cause of error.
I googled it and it seems kind of server error. I would like to ask if I have way to debug the cause of error.
Yes, debugging is the next step. Your code is rather confusing as it returns JSON responses but you have not shared any AJAX or HttpClient making HTTP requests. I assume the 500 error has something to do with code we cannot see.
It allows to know which exact error and then you can look at the relevant place from what could cause this error. When reading it is not uncommon to see multiple possible errors without any way to know if or which one happens or that the problem is caused
by some data you can't see just by reading your code.
Because you have two get methods named "Create", although one has parameters and one doesn't, the "AmbiguousMatchException" error will appear. You can use "[HttpGet (" {id}
")]" before the Create method with parameters.
ASP.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today. Learn more >
Member
32 Points
224 Posts
Debug Server Responded with a status 500
Apr 30, 2020 11:45 AM|thtang|LINK
Hi,
I have a grid table to show all the OptMsgType Record in OptMsgType table by JSON. I can load and delete the table but if I click the "Create" button, it will pop up a blank page ("Create.cshtml"). I check the browser and it shows the error "Failed to load resource: the server responded with a status of 500 ()" in "Settings/OptMsgType/Create:1". I googled it and it seems kind of server error. I would like to ask if I have way to debug the cause of error.
Thank you!
Create.cshtml
OptMsgType.cs
OptMsgTypeController.cs
Index.cshtml
All-Star
53741 Points
24068 Posts
Re: Debug Server Responded with a status 500
Apr 30, 2020 12:12 PM|mgebhard|LINK
Yes, debugging is the next step. Your code is rather confusing as it returns JSON responses but you have not shared any AJAX or HttpClient making HTTP requests. I assume the 500 error has something to do with code we cannot see.
Member
32 Points
224 Posts
Re: Debug Server Responded with a status 500
Apr 30, 2020 12:30 PM|thtang|LINK
Sorry, just supplement this.
Thank you.
All-Star
48740 Points
18193 Posts
Re: Debug Server Responded with a status 500
Apr 30, 2020 02:31 PM|PatriceSc|LINK
Hi,
See https://medium.stackify.com/iis-logs-error-logs-and-more-6-ways-to-find-failed-asp-net-requests-23b16e40db89 and point 3.
It allows to know which exact error and then you can look at the relevant place from what could cause this error. When reading it is not uncommon to see multiple possible errors without any way to know if or which one happens or that the problem is caused by some data you can't see just by reading your code.
Contributor
3090 Points
877 Posts
Re: Debug Server Responded with a status 500
May 04, 2020 10:33 AM|YihuiSun|LINK
Hi, thtang
Because you have two get methods named "Create", although one has parameters and one doesn't, the "AmbiguousMatchException" error will appear. You can use "[HttpGet (" {id} ")]" before the Create method with parameters.
More usage of " HttpGet " can refer to this link.
https://docs.microsoft.com/en-us/aspnet/core/mvc/controllers/routing?view=aspnetcore-3.1#attribute-routing-with-http-verb-attributes
Here is the result.
Best Regards,
YihuiSun