MARKAND Bhatt
MARKAND Bhatt

Reputation: 2630

MVC5 Actionlink: Pass data as query string

Following is my Html.Actionlink

@Html.ActionLink("Change Team", "Edit", "UserPlayers", new { MatchId = ViewBag.MatchId, UserId = ViewBag.UserId })

When i run the application I get this

http://localhost:50013/UserPlayers/Edit?Length=11

as a link.

I dont know from where is the "Length=11" coming.

Upvotes: 5

Views: 7843

Answers (1)

Electric Sheep
Electric Sheep

Reputation: 4320

You need to add a null as the last parameter:

@Html.ActionLink("Change Team", "Edit", "UserPlayers", new { MatchId = ViewBag.MatchId, UserId = ViewBag.UserId }, null)

Without this, you are using the wrong method overload for Html.ActionLink()

Upvotes: 9

Related Questions