I have looked at a good few examples online of how to contact a .Net Core C# method from an Ajax call in Razor Pages - however having gone through a bunch of examples I can't seem to figure out why I can't get it to work for my scenario... Which I dont think is anything special!
I have a button to call this method on click:
and that DeleteSeasonTrip()
method looks like this:
Now, I have the following method setup:
Which lives in the class EditModel:
in the following structure:
If I try to call the ajax request I get the follwoing:
Am I missing a crucial piece of the puzzle here? I feel I have followed the examples I have seen close enuogh, however I am really quite new to Razor Pages for Core so think I am just missing something simple!?
Thanks to Mike Brind comment on the original question, I have gone through this page and applied the Request Verification Token and now all works a treat:
https://www.mikesdotnetting.com/article/336/ajax-posts-in-razor-pages-and-http-400-errors
With this RVT in place I am now able to hit the method in code behind and the request completes successfully.