简体   繁体   中英

C# MVC4 ActionResult ActionFilter for FormCollection

I have the following ActionResults and one is meant to be an override of the other that accepts a FormCollection as a parameter.

   [HttpPost]
    public ActionResult PartialAverageDisplay()
    {
        HomeModel C = new HomeModel();
        ChViewModel D = new ChViewModel();
        D = C.AverageCalculation();

        return PartialView(D);
    }
   [HttpPost]
    public ActionResult PartialAverageDisplay(FormCollection myFcollection)
    {
         HomeModel C = new HomeModel();
         System.Data.DataTable myDT = new System.Data.DataTable();
         myDT = (DataTable)Session["DT"];
         ChViewModel D = new ChViewModel();
         D = C.AverageCalculation(myDT, myFcollection);

            return PartialView(D);
        }

I've been unable to find an example online of how to create an actionfilter attribute for requiring a FormCollection. Everything Ive seen has used an array of strings. Im not experienced with creating actionfilters. Can anyone explain to me how to approach this?

Thanks

MVC does not allow you to have overrides of the same method with the same Action verb (Post, get, etc..). You can only have one HttpPost per method name. It will compile, but you will get an Ambiguous call error at runtime.

This also includes having multiple ActionName's to try to get around the problem. The problem is that the URL can only map to a single action of that type.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM