I am trying to turn a button into a Action Link, the link takes me to another page however I need to send new { id = item.Id }
to my other page and I don't know how else to do this:
@foreach (var item in Model.CurrentPost.Tags)
{
<div class="col-lg-2">
<a href="@Html.ActionLink("" + item.Name + "", "GetPostsByTag", "Post", new { id = item.Id }, null)" class="btn btn-default btn-lg">
@item.Name
</a>
</div>
}
I am getting this error:
A potentially dangerous Request.Path value was detected from the client (<).
When clicking the button the url that it tried to take me to was:
http://localhost:52202/Post/MainDetails/<a href="/Post/GetPostsByTag?id=54">Picture</a>
Have no idea why picture is appended on the end or the href, it should be:
http://localhost:52202/Post/MainDetails/GetPostsByTag?id=54
@Html.ActionLink()
generates an<a>
tag. You do not need to wrap it in another<a>
tag. - just use@Html.ActionLink(item.Name, "GetPostsByTag", "Post", new { id = item.Id }, null)
– user3559349DeleteRule
tocascade
– user3559349