I stumbled on an error when I tried to redirect a user to another view here:
public IActionResult Edit([FromBody]int id)
{
return RedirectToAction("EditProduct", "Admin", new { id = id});
}
After that the view should be generated:
public IActionResult EditProduct(int? id)
{
var Products = _repository.GetProduct(id);
return View(Products);
}
In result the redirect gets into EditProduct View but in the browser it stays in the same page. Am I doing something wrong or is there an exception I do not know about?
As Suman Pathak said in comments MVC does not do redirects using an ajax call. So i passed identificator via js file:
window.location = "/Admin/EditProduct/" + productId;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.