我VisitsController:MVC4控制器/路由不工作
public ActionResult Index(Visits visits, int? id)
{
....
return View(v);
}
,這裏是我的路由配置
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index",
id = UrlParameter.Optional }
);
}
Works: http://localhost:49225/Visits
Does not work: http://localhost:49225/Visits/123
什麼將自定義路線(和強迫它是一個整數)?
對於http:// localhost:49225/Visits/123,您需要創建一個新路由,或使用http:// localhost:49225/Visits/Index/123 –
您是否嘗試使用http:// localhost: 49225 /訪問/索引/ 123? –
@Husein是的,它的工作原理,thx,但我想localhost:49225/Visits/123工作。 – ginalster