[英]mvc 5 RedirectToAction does not return View, stays on the same browser page
當我嘗試將用戶重定向到另一個視圖時,我偶然發現了一個錯誤:
public IActionResult Edit([FromBody]int id)
{
return RedirectToAction("EditProduct", "Admin", new { id = id});
}
之后,應生成視圖:
public IActionResult EditProduct(int? id)
{
var Products = _repository.GetProduct(id);
return View(Products);
}
結果,重定向進入EditProduct View,但在瀏覽器中,它保留在同一頁面中。 我是在做錯什么,還是有我不知道的例外?
正如Suman Pathak在評論中所說,MVC不會使用ajax調用進行重定向。 所以我通過js文件傳遞了identifier:
window.location = "/Admin/EditProduct/" + productId;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.