2011-09-24 3 views
1

DB에서 사용자 지정보기를 제공하기 위해 사용자 지정 VirtualPathProvider를 구현했으며 FileExists 메서드에 중단 점을 넣으면 프레임 워크에서 불필요한 (프로젝트에 대한) 요청을 처리하는 것으로 나타났습니다.MVC 경로 확인 메커니즘을 다시 구성 할 수 있습니까?

  • "~/예/액션/5"
  • "~/예/액션/5.cshtml"예를 들어 나는 비 기존의 행동에 대한 요청 (예 : http://localhost/Example/Action가) 프레임 워크가 보이는 할 때
  • '~/예/액션/5.vbhtml "
  • '~/예/Action.cshtml는"
  • '~/예/Action.vbhtml "
  • '~/Example.cshtml"
  • "~/Example.vbhtml"
  • '~/예/액션/5/default.cshtml "
  • '~/예/액션/5/default.vbhtml"
  • '~/예/액션/5/index.cshtml "
  • '~/예/액션/5/index.vbhtml "
  • '~/favicon.ico의"
  • '~/favicon.ico.cshtml "
  • '~/favicon.ico.vbhtml"
  • "~/favicon.ico/default.cshtml"
  • "~/favicon.ico/default.vbhtml"
  • "~/favicon.ico의/index.cshtml"
  • "~/favicon.ico의/index.vbhtml"

내가 추가 한 경로와 일치하는 요청을 (예를 들어 http://localhost/Test) 프레임 워크 외모에 대한 :

  • "~/테스트"
  • "~/Test.cshtml"
  • "~/Test.vbhtml"
  • "~/테스트/DEF ault.cshtml "
  • "~/테스트/default.vbhtml "
  • "~/테스트/index.cshtml "
  • "~/테스트/index.vbhtml "

도를 초기화하기 전에 제어 장치. 컨트롤러가 초기화 된 후 프레임 워크는 구현 한 사용자 정의 RazorViewEngine에 정의 된대로 뷰를 찾습니다.

이 그래서 문제는 이러한 기본 루트는 제거하는 방법을 할 수있다

 AreaViewLocationFormats = new string[] { }; 
     AreaMasterLocationFormats = new string[] { }; 
     AreaPartialViewLocationFormats = new string[] { }; 
     MasterLocationFormats = new string[] { }; 
     ViewLocationFormats = new string[] { 
      "~/Views/Dynamic/{1}/{0}.cshtml", 
      "~/Views/Dynamic/Shared/{0}.cshtml", 
      "~/Views/{1}/{0}.cshtml", 
      "~/Views/Shared/{0}.cshtml" 
     }; 
     PartialViewLocationFormats = new string[] { 
      "~/Views/Dynamic/{1}/Partial/{0}.cshtml", 
      "~/Views/Dynamic/Shared/Partial/{0}.cshtml", 
      "~/Views/{1}/Partial/{0}.cshtml", 
      "~/Views/Shared/Partial/{0}.cshtml" 
     }; 
     FileExtensions = new string[] { "cshtml" }; 

내 ViewEngine입니까?

답변

0

RouteCollection.RouteExistingFiles 속성과 관련 될 수 있습니까? 필자는 일치하는 파일이 아니라 많은 파일을 확인하는 것이 타당하지 않지만 어떤 차이가 있는지 확인하는 것이 좋습니다.

관련 문제