views:

161

answers:

1

I'm using the code from this blog: http://blog.maartenballiauw.be/post/2009/05/20/ASPNET-MVC-Domain-Routing.aspx to implement subdomains. My goal is to have an area /admin/ that works with urls like: admin.localhost\test\index while my main application is localhost\home\index.

I've implemented the following route:

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
));

And the area /Admin has a controller named TestController and a view named /Test/Index.aspx. But when I try to go the admin.localhost (defined in \hosts file) I get the following error:

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) 

The view has no master page defined.

+1  A: 

I've solved this a while ago, have a check of my blog about routing subdomains to areas.

Hope this helps

TWith2Sugars