一个URL,例如  /Product/Del/10
其中,Product 是 controller
Del 是 action
10 是 action 的唯一参数对应的action是这样写的:[HttpGet]
public ActionResult Del(int? productid){
// do something here.
}上面的 HTTPGet 加不加都无法获取到 productid 的值,也就是 10URL 改成下面这种模式就能接受到/Product/Del/?productid=10请高手指点一下怎么解决?

解决方案 »

  1.   

    应该是你Global里面的路由配置不对吧
      

  2.   

    假设楼主用的是自动生成的路由public ActionResult Del(int? productid)->public ActionResult Del(int? id)
      

  3.   

    我也出现了这个问题!Global文件配置了,但是我Global配置了很多路由,我测试如果把其他的路由删除了,控制器/Action/1就可以,如果带其他的传值就为空            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
                routes.MapRoute(
                    "Index", // Index主页
                    "{controller}/{action}/{name}/{typeid}", // 带有参数的 URL
                    new { controller = "Home", action = "Index", name = "", typeid = "" } // 参数默认值
                );            routes.MapRoute(
                   "GetOrder", // 根据采购订单单号获取产品信息
                   "{controller}/{action}/{_order}",// 带有参数的 URL
                   new { controller = "Purchase", action = "FindProductByOrder", _order = UrlParameter.Optional } // 参数默认值
               );      Action
            public void FindProductByOrder(string _order)
            {
              // HttpContext.cy            Response.Write(1);
            }