2013-02-08 30 views
1

問題:避免大數據在MVC重定向而不使用TempData的

  1. 您有一個自定義控制器動作,它修改了大量的數據(約5MB)。
  2. 您需要將此數據傳遞給您不允許修改的另一個控制器操作。

這樣做的最好方法是什麼?

正常的RedirectToAction會導致巨大的數據發佈。

TempData不能用作解決方法,因爲您無法修改其他控制器來讀取tempdata。

[HttpPost, ActionName("Import")] 
    public ActionResult ImportPost(int id) 
    { 
    var bigData = GetBigData(id); 
    bigData = ManipulateBigDataIntoFormatOtherControllerUnderstands(bigData); 


    // TODO: redirect to other controller (which has HttpPost attribute), somehow?? 
} 
+0

是臨時文件或數據庫事務選項? – 2013-02-08 15:51:37

回答

4

沒關係,想出了一個答案公佈之後:

var c = new Namespace.Controllers.OtherController(); 
c.ControllerContext = ControllerContext; 
return c.Action(bigData);