이 블로그의 코드를 사용하여 http://blog.maartenballiauw.be/post/2009/05/20/ASPNET-MVC-Domain-Routing.aspx 하위 도메인을 구현하고 있습니다. 내 목표는 local/home/index와 같은 메인 애플리케이션이있는 동안 admin.localhost \ test \ index와 같은 URL로 작동하는 영역/admin/that을 갖는 것입니다.영역에 mvc2 라우팅 하위 도메인이 작동하지 않습니다.
나는 다음과 같은 경로를 구현했습니다 :
context.Routes.Add("AdminDomainRoute", new DomainRoute(
"admin.localhost", // Domain with parameters
"{controller}/{action}/{id}", // URL with parameters
new { controller = "test", action = "index", id = "", isAdmin = true }
// Parameter defaults
));
그리고 지역/관리자는 TestController라는 이름의 컨트롤러와 /Test/Index.aspx라는 이름의보기가 있습니다.
System.InvalidOperationException: The view 'index' or its master was not found. The following locations were searched:
~/Views/test/index.ascx
~/Views/Shared/index.ascx
~/Views/Admin/test/index.ascx
~/Views/test/index.aspx
~/Views/Shared/index.aspx
~/Views/Admin/test/index.aspx
~/Views/test/index
~/Views/Shared/index
~/Views/Admin/test/index
at System.Web.Mvc.ViewResult.FindView(ControllerContext context)
at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass14.<InvokeActionResultWithFilters>b__11()
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass14.<>c__DisplayClass16.<InvokeActionResultWithFilters>b__13()
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
뷰가 정의 된 마스터 페이지가 없습니다 : 나는 admin.localhost을 이동하려고 할 때 나는 다음과 같은 오류가 발생합니다 (\ 호스트에서 파일 정의).