我是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 }
);
}
}