从 Controller B 中的 Action-method 方法调用 Controller A 中的 Action-method 方法的最佳方式是什么? 真的有这样的召唤吗?
最佳答案
最好的方法是调用return RedirectToAction()
。
但正确的方法是将相关代码从 Controller /操作移动到外部位置、服务或业务逻辑层。它们驻留在您的 Controller 中是错误的,它不是这个地方,现在让您头痛如何跳转到另一个 Controller 然后再返回。这是错误的。无需寻找解决方法,只需修复您的架构即可。
关于model-view-controller - 从另一个 Controller 调用操作方法的最佳方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9868427/