我正在使用Url.Action,因此我可以创建更复杂的HTML链接,因为ActionLink不允许在其中使用HTML.例:
<a class="uiButton" href="@Url.Action("Areas","Organisations","Manage","Create")" title="New Organisation">
<span class="icon organisations-new">New Organisation</span>
</a>
Run Code Online (Sandbox Code Playgroud)
但是URL没有出现在href?有什么想法吗?:/
你正在使用Url.Action的这个重载
public string Action(
string actionName,
string controllerName,
Object routeValues,
string protocol
)
Run Code Online (Sandbox Code Playgroud)
你肯定使用它错了(没有像"创建"这样的协议).为您使用任何适当的重载.举例来说,如果你有OrganizationsController和Create行动,这段代码将是不够的:
@Url.Action("Create", "Organisations")
Run Code Online (Sandbox Code Playgroud)
如果要路由到另一个区域,请提供routeValues对象new {Area = "anotherAreaName"}.
@Url.Action("Create", "Manage", new {Area = "Organizations"})
Run Code Online (Sandbox Code Playgroud)
这将路由到Organizations区域,在ManageController上创建操作
| 归档时间: |
|
| 查看次数: |
2684 次 |
| 最近记录: |