I want to configure an ASP.NET MVC route that looks like this:
routes.MapRoute( "Default", // Route name "{controller}/{action}/{idl}", // URL with parameters new { controller = "Home", action = "Index", idl = UrlParameter.Optional } // Parameter defaults );
This routes requests that look like this:
Example/GetItems/1,2,3
... to my controller action:
public class ExampleController : Controller { public ActionResult GetItems(List<int> id_list) { return View(); } }
The question is, what did I configure to convert the idl url parameter from string to List<int> and called the corresponding controller action?
I saw here a question that used OnActionExecuting to preprocess the string, but did not change the type. I donβt think this will work for me here, because when I override OnActionExecuting in my controller and check the ActionExecutingContext parameter, I see that the ActionParameters dictionary already has an idl key with a null value - presumably an attempt to flush from a string to List<int> ... this is the routing part that I want to control.
Is it possible?
source share