gpt4 book ai didi

c# - 没有 asp-controller 属性的 ASP anchor 标记助手 asp-action 属性

转载 作者:太空宇宙 更新时间:2023-11-03 12:44:09 24 4
gpt4 key购买 nike

在我的 ASP.NET Core RC2 应用程序中,我使用 VS2015 view Wizard 创建了一个 View ,我选择了 Details demplate。在 View 的末尾,它创建了以下 HTML 标记。如果您注意到 anchor 标记具有 asp-action 属性但没有 asp-Controller 属性。但是 Edit 和 Index 链接将我带到正确的 Controller ,该 Controller 是向导用来创建 Details 模板的 Controller 。我的假设是,默认情况下 Edit 和 Index 操作 在 Details 模板使用的同一 Controller 中调用。我的假设正确吗?哪里需要 asp-controller 属性?如果不存在,假设是什么?

详情 View :

...other tags here...
<div>
<a asp-action="Edit" asp-route-id="@Model.CustomerID">Edit</a> |
<a asp-action="Index">Back to List</a>
</div>

最佳答案

您的假设是正确的,如果未提供 asp-controller 属性,链接将使用与当前操作相同的 Controller 生成。

关于c# - 没有 asp-controller 属性的 ASP anchor 标记助手 asp-action 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37929933/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com