Search code examples
asp.net-mvcumbracoumbraco7

Parameters in ActionResult


In migrating a Vanilla MVC project to a Vanilla Umbraco project, i am facing a couple of issues. One of them is with the query parameters, and transferring them to my Index.

Old ActionResult from working MVC project:

public ActionResult Index(int value1, int value2, bool value3 = false)
{...}

New ActionResult, working in a Vanilla Umbraco project

public override ActionResult Index(RenderModel model)
{...}

But i need the parameters (coming from querystring) from the original project. I tried simply adding them:

public override ActionResult Index(RenderModel model, int value1, int value2, bool value3 = false)
{...}

But when i do the latter, i get the error 'Controller.Index(RenderModel, int, int, bool): no suitable method found to override'

What am i missing?


Solution

  • You can not pass those values as parameters. You should extract them from query string instead.

    public override ActionResult Index(RenderModel model)
    {
         var value1 = Request["value1"];
         var value2 = Request["value2"];
         var value3 = Request["value3"];
         ...
    }