2012-07-12 4 views
1

asp.net 라우팅을 사용하여 asp.net webforms에서 확장 할 수없는 URL을 구현하려고합니다.asp.net 라우팅에서 폴더로 라우팅하지 못하도록

routes.Add("MyRouting", new Route("{PagePath}", 
new MyRouteHandler("~/Default.aspx"))); 

이렇게 확장하면 URL이 정상적으로 작동하지만 라우팅 경로가 실제 실제 경로로 존재하는 경우가 있습니다.

EG : 루트에 서비스라는 실제 폴더가 있으므로 로컬 호스트/서비스가 404 예외를 throw합니다.

어떻게 디렉토리 라우팅을 건너 뛰 시나요?

감사

답변

1

다음 코드는 당신이 오는 URL의 가까운 제어를 얻을 필요가 해답이 될 수 있습니다.

public static void RegisterRoutes(RouteCollection routes) { 

    // example: ignore routes with this file extension and with any extra text afterwards 
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 

    ... 

    // example: new route to modify an URL and remove the .aspx extension 
    routes.MapRoute(
     "UrlManagerRoute", 
     "{*url}", 
     new { controller = "MyController", action = "MyAction" }, 
     new { url = @".*\.aspx(/.*)?" } 
    ); 
    ... 
} 
관련 문제