ASP.NET MVC - passing parameters to the controller
Your routing needs to be set up along the lines of {controller}/{action}/{firstItem}
. If you left the routing as the default {controller}/{action}/{id}
in your global.asax.cs
file, then you will need to pass in id
.
routes.MapRoute(
"Inventory",
"Inventory/{action}/{firstItem}",
new { controller = "Inventory", action = "ListAll", firstItem = "" }
);
... or something close to that.
you can change firstItem to id and it will work
you can change the routing on global.asax (i do not recommed that)
and, can't believe no one mentioned this, you can call :
http://localhost:2316/Inventory/ViewStockNext?firstItem=11
In a @Url.Action would be :
@Url.Action("ViewStockNext", "Inventory", new {firstItem=11});
depending on the type of what you are doing, the last will be more suitable. Also you should consider not doing ViewStockNext action and instead a ViewStock action with index. (my 2cents)