3

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?

Ortund
  • 8,095
  • 18
  • 71
  • 139

2 Answers2

2

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

@Html.ActionLink("Register", "Register", "Home", null, new { @class = "button active-button" }) 
NightOwl888
  • 55,572
  • 24
  • 139
  • 212
  • I thought it was but didn't know what else to do... Note to self: learn razor properly :/ Anyway thanks :) added the null and it works perfectly – Ortund Sep 20 '15 at 16:05
0

This is due to wrong overload as mentioned in another answer.If you are confused about which overload should be used then you can use visual studio intellisence.

In MVC3+ you have this

Html.ActionLink("Register", 
                "Register",   // <-- ActionMethod
                "Home",  // <-- Controller Name.
                 null, // <-- Route arguments..you don't need this
                new {@class = "button active-button"}// <-- htmlArguments
                )
Puzzled
  • 15
  • 2