Rahul Patel

Rahul Patel

  • 1.6k
  • 105
  • 10.9k

child actions are not allowed to perform redirect actions.

Aug 18 2018 3:09 PM
child actions are not allowed to perform redirect actions. partial view
 
I'm trying to use Create view with the index view to show the created item in the same page. For that I'm using _CreateCategory as the partial view and I added following to the index view.
 
When I am postback the form then my child action uses the http post method insted of http get method.
 
// In view
@Html.Action("Create", "Products")
My controller's get and post methods as follows for the Create
[HttpGet]
public ActionResult Create()
{
Products pro = new Products();
return PartialView("Create", pro);
}
[HttpPost]
public ActionResult Create(Products pro)
{
if (ModelState.IsValid)
{
db.Categories.Add(category);
db.SaveChanges();
return RedirectToAction( "Index");
}
return RedirectToAction("Index");
}
 
My index method as follows
 
public ActionResult Index()
{
//get data from db
return View(Model);
}
[HttpPost]
public ActionResult Index(string a, string B)
{
//get data from db
return View(Model);
}

Answers (4)