映射路由 - HTTP错误404.0 - 未找到

时间:2018-03-04 20:28:38

标签: c# asp.net-mvc asp.net-mvc-routing

我是ASP.Net MVC的新手,当我尝试绘制路线时,我收到了404错误。

如果有人能帮我找出我的错误,我将不胜感激。

控制器:

public ActionResult MoviesByRelease(int year,int month)
{

    return Content( year +"/"+ month);
}

RouteConfig

public class RouteConfig
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
           name: "MoviesByReleaseDate",
           url: "movies/released/{year}/{month}",
            new { controller = "Movies", action = "MoviesByRelease" }
            , new { year=@"\d{4}" , month=@"\d{2}" });

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );
    }
}

0 个答案:

没有答案