gpt4 book ai didi

jquery - 如何重定向到正确的 Controller 操作方法

转载 作者:行者123 更新时间:2023-12-01 08:18:57 25 4
gpt4 key购买 nike

我有一个部分 View ,已在产品的多个地方使用。在此 View 中,我通过 Url.Action(“MyActionMethod ”,10) 进行 JSON 调用,从 Home Controller 调用此方法 MyActionMethod。我的问题是,当我从不同的地方使用这个部分 View 时(假设在 AccountController 的上下文中使用 MyView1 ),它会尝试搜索 Account/MyActionMethod 而该方法在 Home/MyActionMethod 中可用。如果我将代码更改为 Url.Action("/Home/MyActionMethod",10),它基本上会查找 Account/Home/MyActionMethod 。

有什么想法吗?

最佳答案

Url.Action("MyActionMethod", "MyController")

或者如果您正在使用区域并且想要指定根:

Url.Action("MyActionMethod", "MyController", new { area = "" })

关于jquery - 如何重定向到正确的 Controller 操作方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8510420/

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