网址操作未输出网址 [英] Url.Action not outputting URL

查看:69
本文介绍了网址操作未输出网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Url.Action,因此我可以创建更复杂的HTML链接,因为ActionLink不允许在其中添加HTML.示例:

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>

但是URL没有出现在 href 中吗?有什么主意吗? :/

However the URL doesn't appear in the href? Any ideas why ? :/

推荐答案

您正在使用 Url.Action的重载

You are using this overload of Url.Action

public string Action(
    string actionName,
    string controllerName,
    Object routeValues,
    string protocol
)

您肯定使用了错误的代码(没有创建"之类的协议).为您使用任何适当的重载 .例如,如果您具有OrganizationsControllerCreate操作,则此代码就足够了:

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")

如果要路由到另一个区域,请提供诸如new {Area = "anotherAreaName"}之类的routeValues对象.

If you want to route to another area, supply routeValues object like new {Area = "anotherAreaName"}.

@Url.Action("Create", "Manage", new {Area = "Organizations"})

这将路由到组织"区域,在ManageController上创建操作

This will route to Organizations area, Create action on ManageController

这篇关于网址操作未输出网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆