I'm working on upgrading a .NET Framework 4.8 app to .NET Core 8.
Currently experiencing an issue where both Html.BeginForm
and the form helper tag sometimes render the wrong action.
In Framework 4.8, I have a form like this:
<form method="post" action="/Controller/Action?paramOne=123">
...
</form>
In Core 8, the same form renders like this instead:
<form method="post" action="[paramOne, 123]">
...
</form>
I get this result with Html.BeginForm
and also with <form asp-controller="Controller" asp-action="Action" method="post">
.
What might be causing this result?
EDIT: after some more testing, I've found that this is happening even when I use the <!form></!form>
opt out syntax; something is causing the form tag to be rewritten no matter what
I found the answer, and it was custom code in a layout:
The .cshtml
filed I'd been editing had a form
tag in it, but so did a parent layout, and that one had custom code to create the action
parameter. That code was using Context.Request.Query
, which renders its params as `[key, value]`.
I changed it to Context.Request.QueryString
and got the result I was looking for.