1

I want to use @Url.Action to pass multiple parameters through the URL in an ASP.NET Core 2.0 Razor Page. I don't know which tag helper I should use.

@model Memberships.Models.SmallButton

<a asp-page="@Url.Action(Model.Action)@Model.ActionParameters" 
   class="btn @Model.ButtonType btn-sm">
     <span class="glyphicon [email protected]"></span>
     <span class="sr-only">@Model.Text</span>
</a>
1

1 Answer 1

0

As far as I know you cannot do that with AnchorTagHelper. If you want to add parameters to it then you have to do this one by one:

<a asp-action="Edit" asp-route-id="@Model.Id" asp-route-something="Something">Link</a>

If you want to use Url.Action then you have to pass it via href parameter:

<a href="@Url.Action(Model.Action)">Link</a>

You can use UrlHelper.Action(string action, object values) to pass additional route values:

<a href="@Url.Action(Model.Action, Model.ActionParameters)">Link</a>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.