区域之间的 RedirectToAction?

发布于 2024-08-04 22:18:34 字数 31 浏览 6 评论 0原文

有没有办法重定向到不同区域上的特定操作/控制器?

Is there a way to redirect to a specific action/controller on a different Area?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

岛徒 2024-08-11 22:18:34

你尝试过这个吗?:

return RedirectToAction("action", "controller", new { area = "area" });

Did you try this?:

return RedirectToAction("action", "controller", new { area = "area" });
暖阳 2024-08-11 22:18:34

你的回答对我很有帮助。只是想在下面添加:

如果您想从一个区域重定向到另一个区域,上面的代码效果很好。

而且,如果您想从一个区域重定向到区域文件夹中不存在的控制器/视图(即在大多数情况下,您的前端),您可以指定area =“”。

IE

return RedirectToAction("action", "controller", new { area = "" });

Your answer was helpful to me. Just wanted to add below:

If you want to redirect from one area to another area, above code works well.

And, if you want to redirect from one area to a controller/view which is not there in the area folder (i.e. in most cases, your front end), you can specify area = "".

i.e.

return RedirectToAction("action", "controller", new { area = "" });
∞琼窗梦回ˉ 2024-08-11 22:18:34

试试这个

return RedirectToAction("ActionName", "AreaName/ControllerName");

Try this

return RedirectToAction("ActionName", "AreaName/ControllerName");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文