0

別のコントローラーのアクションからコントローラーのビューを呼び出してレンダリングするにはどうすればよいですか。私はこれを持っています、製品コントローラーのアクション:

 public ActionResult SortedLists(List<string> items, string ShopID)
    {
        //Do sth...

        db.SaveChanges();
        return RedirectToAction("Index", "ControlPanel", new { ID = ShopID });
    }

Index は ControlPanel Controller のアクション (ビュー) です。

public ActionResult Index(int ID)
    {
         ViewBag.theRelatedShopID = ID;     
         return View();
    }

Indexをレンダリングしてブラウザに表示するにはどうすればよいですか???

4

1 に答える 1

2
public ActionResult SortedLists(List<string> items, string ShopID)
{
    //Do sth...
    db.SaveChanges();

    return View("~/ControlPanel/Index.cshtml", (object)ShopID);
}

ここでは、ShopIdasモデルをインデックスビューに渡します。このビューが一部のモデルに強く入力されている場合は、次のモデルを渡す必要があります。

MyViewModel model = ...
return View("~/ControlPanel/Index.cshtml", model);
于 2013-01-31T10:53:06.187 に答える