我需要从控制器 A 调用控制器 B 操作 FileUploadMsgView 并需要为其传递一个参数。
它不会去控制器 B 的FileUploadMsgView()。
FileUploadMsgView()
这是代码:
控制器A:
private void Test() { try { //some codes here ViewBag.FileUploadMsg = "File uploaded successfully."; ViewBag.FileUploadFlag = "2"; RedirectToAction("B", "FileUploadMsgView", new { FileUploadMsg = "File uploaded successfully" }); } }
ControllerB(接收部分):
public ActionResult FileUploadMsgView(string FileUploadMsg) { return View(); }
控制器只是类 - 新建一个并像调用任何其他类成员一样调用 action 方法:
var result = new ControllerB().FileUploadMsgView("some string");