ASP.Net MVC - post from one controller to another (action to action)

前端 未结 5 1757
孤街浪徒
孤街浪徒 2021-02-08 00:47

Is is possible to do a post from an Action \"Save\" in a controller \"Product\" to an Action \"SaveAll\" in a controller \"Category\"??

And also passing

5条回答
  •  花落未央
    2021-02-08 01:40

    public class Product : Controller
    {
        ...
        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Save(FormCollection productValues)
        {
            ...
            RedirectToAction("SaveAll", "Category", new { formValues = productValues });
        }
        ...
    }
    
    public class Category : Controller
    {
        ...
        public ActionResult SaveAll(FormCollection formValues)
        {
            ...
        }
    }
    

    The assumption is that you are executing the POST in the context of the Product.

提交回复
热议问题