ASP.NET MVC - passing parameters to the controller

后端 未结 10 1329
小蘑菇
小蘑菇 2020-11-28 23:36

I have a controller with an action method as follows:

public class InventoryController : Controller
{
    public ActionResult ViewStockNext(int firstItem)
           


        
10条回答
  •  情书的邮戳
    2020-11-29 00:00

    The reason for the special treatment of "id" is that it is added to the default route mapping. To change this, go to Global.asax.cs, and you will find the following line:

    routes.MapRoute ("Default", "{controller}/{action}/{id}", 
                     new { controller = "Home", action = "Index", id = "" });
    

    Change it to:

    routes.MapRoute ("Default", "{controller}/{action}", 
                     new { controller = "Home", action = "Index" });
    

提交回复
热议问题