I am trying to create an action link within a view for my controller RequestedService which takes the user to another controller and action in the form:
/ItemsForService/Create/{id}
With ItemsForService being the controller that the create function exists in.
So far I have:
@Html.ActionLink("Add Item", "ItemsForService", "Create", New With {.id = currentItem.RequestedServiceId})
However this seems to pass it as Create?=id and not Create/id
How would I pass as the latter?
Use the correct overload of ActionLink to get the intended result
You don’t need the
.id = ...it’s justid = ...The overload is
ActionLink(string linkText, string actionName, string controllerName, object routeValues, object htmlAttributes)Adding the last parameter of
Nothingas null HTML attributes is necessary when you supply parameters to the action. Or if you actually needed to apply HTML Attributes to the link, you would use: