Appending "id=" parameter in Html.ActionLink in MVC 4

 @Html.ActionLink("View Details", "Index", "PatientVisitDetail", new {id=item.Id}, null)|

produces some link like, http://localhost:19456/PatientVisitDetail/Index/1

But, I want a link that says something like,

http://localhost:19456/PatientVisitDetail/Index/?id=1

Upvotes: 2

Views: 2685

Answers (1)

musefan
musefan

Reputation: 48415

That is likely due to how your routing is setup. Not sure if there is a better way, but this should work:

<a href="@(Url.Action("Index", "PatientVisitDetail") + "?id=" + item.Id)">View Details</a>

Upvotes: 4

Related Questions