I'm using Url.Action so that I can create more complex HTML links as ActionLink doesn't allow HTML inside them. Example:
<a class="uiButton" href="@Url.Action("Areas","Organisations","Manage","Create")" title="New Organisation">
<span class="icon organisations-new">New Organisation</span>
</a>
However the URL doesn't appear in the href
? Any ideas why ? :/
You are using this overload of Url.Action
public string Action(
string actionName,
string controllerName,
Object routeValues,
string protocol
)
And you are definitely using it wrong (no protocol like "Create"). Use any of appropriate overloads for you. For example, if you've got OrganizationsController
and Create
action, this code will be enough:
@Url.Action("Create", "Organisations")
If you want to route to another area, supply routeValues object like new {Area = "anotherAreaName"}
.
@Url.Action("Create", "Manage", new {Area = "Organizations"})
This will route to Organizations area, Create action on ManageController
In my case I had an empty string because "area" parameter was wrong.