I have an Html.ActionLink helper that is passing an unexpected query string of ?Length=4. This is a problem for me because I need to pass my own string.
I am unable to use the route values parameter of the Html.ActionLink in this situation because the value I need to pass is a user selected javascript value from the rendered page.
How do I prevent this unexpected string from being passed?
This is my ActionLink:
@Html.ActionLink("Edit Attendees", "Attendees", "Smrt", new { @class= "btn btn-outline-secondary mr-2" })
This is the result:
http://localhost:55577/Smrt/Attendees?Length=4
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
I discovered that if I add the argument parameter for route values as a ‘null’ it removes this unexpected query string.
@Html.ActionLink("Edit Attendees", "Attendees", "Smrt", null , new { @class= "btn btn-outline-secondary mr-2" })
this then allowed me to pass the parameter I needed via jQuery.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0