문제

vs.net이 생성하는 기본 경로를 사용하고 싶지 않습니다.

routes.MapRoute(
    "Default",                                             // Route name
    "{controller}/{action}/{id}",                          // URL with parameters
    new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);

나는 www.example.com/ 페이지를 얻는 경로 만 원한다.(참고 : www.example.com/default 만 Plain www.example.com만이 HomeController Action = Index에 매핑하기를 원하지 않습니다).

도움이 되었습니까?

해결책

방금 어제 MVC와 함께 놀기 시작했고 (베타 버전) 웹 구성에 이것을 가지고 있습니다 (IIS 6.0의 경우 IIS 7.0 용 .aspx를 제거).

public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.MapRoute("Default", "{controller}.aspx/{action}/{id}", new { controller = "Home", action = "Index", id = "" });
            routes.MapRoute("Empty", "", new { controller = "Home", action = "Index", id = "" });
        }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top