Hi, @mc ,
If you want to access method in Razor Page by ajax, You just need to add ?handler=(method name without OnPost or OnGet)
in Url like:
type: "POST",
url: '/Index?handler=Delete',
headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() },
Attention: You also need to check If the form contains RequestVerificationToken
(contains by default), If the from doesn't contains that token, You need to add:
@Html.AntiForgeryToken()
In your form.
-----------------------------------------------------------------------------------------------------------------
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards,
Xinran Shen