MVC 5 Routing Attribute

后端 未结 4 1298
梦如初夏
梦如初夏 2020-12-19 00:37

I have the Home Controller and my Action name is Index. In My route config the routes like below.

routes.MapRoute(
    \"Default\",   // Route name
    \"{c         


        
4条回答
  •  天命终不由人
    2020-12-19 00:58

    try changing the index action to this:

    public ActionResult Index(int? id = null) 
    {
      return View(); 
    }
    

    This should do the trick. So you can pass the id as a param with the "/{value}" or just use "/?id={value}"

提交回复
热议问题