Ad

Iam Trying To Use Html.ActionLink To Generate Url With QueryString Parameter At The End Of It

- 1 answer

I am trying to use Html.ActionLink to generate URL with query String parameter at the end of it like:

Controller/Action?id=5

But what i get is:

Controller/Action/5

Using :

@Html.ActionLink((string)ViewBag.Back, "Action", "Controller", new{id = Model.Id }, new { })

How can i pass the id parameter as "?id=" not after "/" Thanks

Ad

Answer

change action header

public ActionResult Details(int? detailsId)

and adjust link

Html.ActionLink((string)ViewBag.Back, "Action", "Controller", new{detailsId = Model.Id }, new { })
Ad
source: stackoverflow.com
Ad