ASP.Net MVC: Form with Get Losing Parameters on Submit Method

Say I have a route like this:

"{controller}/{action}/{roomId}/{name}"

And a form action like this (And yes, it looks like this happens in action in html, that is, processing the mail server):

Room/Index/6/SomeThing?pageNumber=1&amountToShow=5

And the form is simple:

<form action = "Room/Index/6/SomeThing?pageNumber=1&amountToShow=5" method="get">
   <button type="submit">SomeButton</button>
</form>

Now that the button is clicked, the request somehow seems to partially lose the page number Number = 1 & AmountToShow = 5. In fact, when I looked at the ActionExecutingContext.ActionParameters list, there are parameters (pageNumber and amountToShow), but no values. I even looked in the request, and there are no request parameters, despite the fact that it knows that the URL is “Room / Index / 6 / SomeThing? PageNumber = 1 & amountToShow = 5”.

I thought that maybe this was due to the button and form, and maybe it was not possible, but then I adjusted the route:

"{controller}/{action}/{roomId}/{name}/{pageNumber}/{amountToShow}"

, , URL- :

 Room/Index/6/SomeThing/1/5

, , , . ?

UPDATE

, , , . , .

+3
2

?

, :

<form action = "Room/Index/6/SomeThing" method="get">
    <input type="hidden" name="pageNumber" value="1" />
    <input type="hidden" name="amountToShow" value = "5" />
    <button type="submit">SomeButton</button>
</form>
+3

, , get it appends '? formvalue = value & otherfield = annothervalue... . , "? Stuff = value" IIS/ASP.

+2

Source: https://habr.com/ru/post/1713682/


All Articles