The route you defined:
[Route("{page}/{size}")]
public ActionResult MyView(int page = 0, int size = 25, FilterModel filterModel = null)
{
...
}
Does not match the URL you want:
http://localhost/MyController/MyView/11/25?someID=0
You need to ensure they are the same (assuming you are not using a RoutePrefix
attribute on the controller):
[Route("MyController/MyView/{page}/{size}")]
public ActionResult MyView(int page = 0, int size = 25, FilterModel filterModel = null)
{
...
}
The reason why the URL http://localhost/MyController/MyView?someID=0
works is most likely that it is matching your Default
route and passing the correct controller and action names to the framework to get to the action method.
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
Note also that you need to have route.MapMvcAttributeRoutes()
before your default route in order to enable attribute routing.