Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 2 asp.net mvc 2:SportsStore应用程序:当前的操作请求不明确_Asp.net Mvc 2 - Fatal编程技术网

Asp.net mvc 2 asp.net mvc 2:SportsStore应用程序:当前的操作请求不明确

Asp.net mvc 2 asp.net mvc 2:SportsStore应用程序:当前的操作请求不明确,asp.net-mvc-2,Asp.net Mvc 2,我正在研究下一本书第4章中的SportsStore示例,我被卡住了 Pro Asp.net mvc框架 我得到以下错误: 控制器类型“ProductsController”上操作“List”的当前请求在以下操作方法之间不明确: WebUI.Controllers.ProductsController类型上的System.Web.Mvc.ViewResult List() WebUI.Controllers.ProductsController.类型上的System.Web.Mvc.ViewRes

我正在研究下一本书第4章中的SportsStore示例,我被卡住了

Pro Asp.net mvc框架

我得到以下错误:

控制器类型“ProductsController”上操作“List”的当前请求在以下操作方法之间不明确: WebUI.Controllers.ProductsController类型上的System.Web.Mvc.ViewResult List() WebUI.Controllers.ProductsController.类型上的System.Web.Mvc.ViewResult列表(Int32)

我的路由器代码如下所示:

        public static void RegisterRoutes(RouteCollection routes)
        {



            routes.MapRoute(
                null, // Route name
                "", // URL with parameters
                new { controller = "Products", action = "List", page=1 }
            );


            routes.MapRoute(
                null, // Route name
                "Page{page}", // URL with parameters
                new { controller = "Products", action = "List" }, // Parameter defaults
                new { page = @"\d+" }
            );
}
public ViewResult List()
{
    return View(productsRepository.Products.ToList());
}

public ViewResult List(int page)
{
    return View(productsRepository.Products
                                .Skip((page - 1) * PageSize)
                                .Take(PageSize)
                                .ToList());
}
控制器代码如下所示:

        public static void RegisterRoutes(RouteCollection routes)
        {



            routes.MapRoute(
                null, // Route name
                "", // URL with parameters
                new { controller = "Products", action = "List", page=1 }
            );


            routes.MapRoute(
                null, // Route name
                "Page{page}", // URL with parameters
                new { controller = "Products", action = "List" }, // Parameter defaults
                new { page = @"\d+" }
            );
}
public ViewResult List()
{
    return View(productsRepository.Products.ToList());
}

public ViewResult List(int page)
{
    return View(productsRepository.Products
                                .Skip((page - 1) * PageSize)
                                .Take(PageSize)
                                .ToList());
}
我错过了什么

我的网址如下:

        public static void RegisterRoutes(RouteCollection routes)
        {



            routes.MapRoute(
                null, // Route name
                "", // URL with parameters
                new { controller = "Products", action = "List", page=1 }
            );


            routes.MapRoute(
                null, // Route name
                "Page{page}", // URL with parameters
                new { controller = "Products", action = "List" }, // Parameter defaults
                new { page = @"\d+" }
            );
}
public ViewResult List()
{
    return View(productsRepository.Products.ToList());
}

public ViewResult List(int page)
{
    return View(productsRepository.Products
                                .Skip((page - 1) * PageSize)
                                .Take(PageSize)
                                .ToList());
}

谢谢

删除
列表()
控制器方法。在书中,它指出您需要将现有的
List()
方法更新为您当前拥有的
List(int page)