1
我查看了與重定向到視圖相關的其他問題,但似乎沒有解決我的問題。我有一箇中間步驟來實現我的創建操作,並且我似乎無法將該步驟的視圖重定向到創建視圖。我的實際代碼的近似值是:ASP.NET MVC-無法重定向到創建動作
public ActionResult SelectDependancy()
{
ViewBag.ProductID = new SelectList(db.Products, "ID", "Name");
ViewBag.ComponentID = new SelectList(db.Components, "ID", "Name");
return View();
}
這個動作的觀點有導致對SelectDependancy(string, string)
調用POST方法。
這個職位是一個標準的POST,而不是一個js的AJAX POST
[HttpPost]
[ValidateAntiForgeryToken]
public void SelectDependancy(string ProductID, string ComponentID)
{
FilteredCreate(ProductID, ComponentID);
}
private ActionResult FilteredCreate(string ProductID, string ComponentID)
{
//Filter values based on ProductID + ComponentID
return RedirectToAction("Create");
}
的return RedirectToAction("Create");
似乎並沒有工作。我也嘗試將其更改爲return View("Create")
(更改方法的返回類型)
如何重定向到創建操作「似乎不工作」?它具體失敗了?在你最後的代碼片段中,'SelectDependancy'動作不會返回任何*,所以我不清楚你在做什麼。 – David
是否有過濾FilteredCreate的原因? –
將'public void SelectDependancy'更改爲'public ActionResult SelectDependancy'。並在方法'返回FilteredCreate(ProductID,ComponentID);' – adiga