Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 370
MARKAND Bhatt Avatar asked Apr 07 '14 14:04

MARKAND Bhatt


1 Answers

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()

like image 79
Electric Sheep Avatar answered Oct 24 '22 02:10

Electric Sheep