开发者

Url.Action not outputting URL

开发者 https://www.devze.com 2023-04-09 02:16 出处:网络
I\'m using Url.Action so that I can create more complex HTML links as ActionLink doesn\'t allow HTML inside them. Example:

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 i开发者_运维知识库deas 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消