POST URL is missing handler query string in Razor Page

Multi tool use
POST URL is missing handler query string in Razor Page
I'm having an issue where my form submission url does not have a query string which points to the handler in the Code Behind. As a result I'm getting a 400 (bad request) error.
The request URL looks like this: http://localhost:60900/EventRename
http://localhost:60900/EventRename
When it should look like this:http://localhost:60900/EventRename?handler=RenameEvent
http://localhost:60900/EventRename?handler=RenameEvent
Here's the .cshtml
<form asp-page-handler="RenameEvent" method="post">
@Html.DropDownListFor(x => x.RenameDataSource, Model.DataSources, "-- select data source --")
@Html.DropDownListFor(x => x.RenameTempEvent, Model.RenameTempEvents, "-- select event type --")
@Html.DropDownListFor(x => x.NewName, Model.EventTypes, "-- select event type --")
Start Renaming
</form>
It might be related, but I've also noticed that the form data is missing the '__RequestVerificationToken', which should be included by default in Razor pages?
To clarify, I'm not expecting to see the data from the form in the URL. I'm expecting to see a handler reference so the Razor Code Behind knows which method to run when the form is submitted. See this section: https://docs.microsoft.com/en-us/aspnet/core/razor-pages/#multiple-handlers-per-pagethe URL path that submits to OnPostJoinListAsync is http://localhost:5000/Customers/CreateFATH?handler=JoinList
the URL path that submits to OnPostJoinListAsync is http://localhost:5000/Customers/CreateFATH?handler=JoinList
2 Answers
2
@using (Html.BeginForm(ActionName, ControllerName, new { handler = "value of your handler" }, FormMethod.Post))
Now you can submit the form it will give you the value for the same.
your form method is post try to use get if you want to see the data string in url.
https://developer.mozilla.org/en-US/docs/Learn/HTML/Forms/Sending_and_retrieving_form_data
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
I'm not expecting to see the form data, but the post request will go to a specific URL specified by the 'asp-page-handler'. See the bottom of this section here: docs.microsoft.com/en-us/aspnet/core/razor-pages/…
– Lukeyb
Jul 3 at 6:44