C
C#2y ago
Nophi

❔ Help in CRUD Update in .net Core and cshtml

I apologize cause this is a simple question, I am studying .net and I really want to be able to make an Update function I have created a .net 6 MVC solution I created a CardsController: https://codeshare.io/WdD79d I created a route for my actions: https://codeshare.io/Rb4NOB I created a function in cshtml for the Delete and Update: https://codeshare.io/YLJgKb And when I call the UpdateCard function in the cshtml I get two errors in the console: PUT https://localhost:44307/Cards/Update/9 net::ERR_ABORTED 400 Error updating card. Note: The Delete Function works Can you look at my simple code and point out where the error might be?
4 Replies
Angius
Angius2y ago
Any p[articular reason you don't use attribute routing? And I see the issue Your Update endpoint is [HttpGet] but in your JS code you send a PUT request to it So change [HttpGet] to [HttpPut]
Nophi
NophiOP2y ago
No, I'm just newbie trying to learn
Nophi
NophiOP2y ago
There are two [http] Update, one with [HttpGet] and one with [HttpPut]
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server