나는 그것이 일반적인 방법 알고 :routes.MapRoute 혼란
routes.MapRoute
(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
을하지만이 같은 시도하는 경우 :
routes.MapRoute
(
name: "Defaults",
url: "Home/Index/1"
);
그것은 프로젝트를 실행하려면 오류를 제공하지 않습니다. 나는 내 HomeController
에 Controller = Home
Action = Index()
을 가지고 있지만 왜이 웹 사이트에 http://localhost:1702/Home/Index/1
을 입력하는 동안 오류가 발생합니까?
Error: The matched route does not include a 'controller' route value, which is required.
라우팅에 필수적인 부분은 무엇입니까? 또 다른 질문은 : 우리가 왜 Route Name
이 필요한지 ??
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
'routes.MapRoute ( 이름 : "기본", URL : "{컨트롤러}/{동작}/{ID}", 기본값 = "홈"새로운 {컨트롤러, 액션 = "인덱스", ID = UrlParameter.Optional} ); –
아니요. 나 같은 것을 시도하면 오류가 발생하지 않습니다. 나는 길을 안다.지도가 너처럼된다. 기본적으로 세 부분으로 구성됩니다. 이름, URL 및 기본값, 나는 이것을 알고 –
아마 [this] (http://stackoverflow.com/questions/23752298/mvc-routing-whyi-i-can-not-ignore-defaults-the-matched-route-does -not-include-a) 도움이 될까요? 귀하의 질문은 중복 것처럼 보입니다. –