Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is my MVC actionlink taking me to the URL with a Length querystring value?

There isn't really much I can do in the way of explanation on this one.

Simply put, I'm trying to render this link:

<a class="button active-button" href="/Home/Register">Register</a>

My ActionLink looks like this:

@Html.ActionLink("Register", "Register", "Home", htmlAttributes: new { @class = "button active-button" })

Which renders this link:

<a class="button active-button" href="/Home/Register?Length=4">Register</a>

I don't understand where the QueryString value is coming from so where have I made my mistake?

like image 554
Ortund Avatar asked Nov 20 '25 09:11

Ortund


1 Answers

This is happening because you are calling the wrong overload of ActionLink.

@Html.ActionLink("Register", "Register", "Home", null, new { @class = "button active-button" }) 
like image 50
NightOwl888 Avatar answered Nov 22 '25 04:11

NightOwl888



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!