title: Bind route to custom physical path in mvc4
body: <p>I want to set up the routes to open views depend on the custom parameter "theme",
  like this:</p>
  
  <pre><code>http://localhost/black/home   to open  ~/themes/black/views/home/index.cshtml
  http://localhost/white/home   to open  ~/themes/white/views/home/index.cshtml
  </code></pre>
  
  <p>the name of theme is dynamic, and I registered routes like this:</p>
  
  <pre><code>    routes.MapRoute("ThemeRoute", "{theme}/{controller}/{action}/{id}"
          , new
          {
              theme = "default",
              controller = "Home",
              action = "Index",
              id = UrlParameter.Optional
          });
  </code></pre>
  
  <p>but it doesn't work. How could I bind the custom route "{theme}/{controller}/{action}/{id}" to the custom physical path like "~/themes/{theme}/views/{view}/{action}"? or impossible?
  I'd appreciate if anyone could give me advices.</p>
  
  <p><strong>Update:</strong>
  I decompiled the class <code>System.Web.Mvc.RazorViewEngine</code> and find out how to define my own custom physical path, like this:</p>
  
  <pre><code>  public sealed class ThemeViewEngine : RazorViewEngine
    { 
          private ThemeViewEngine(IViewPageActivator viewPageActivator)
              : base(viewPageActivator)
          {
              //...
              AreaViewLocationFormats = new[]
              {
                  "~/Areas/{2}/Themes/{3}/Views/{1}/{0}.cshtml",
                  "~/Areas/{2}/Themes/{3}/Views/Shared/{0}.cshtml",
                  "~/Areas/{2}/Views/{1}/{0}.cshtml",
                  "~/Areas/{2}/Views/Shared/{0}.cshtml"
              };
              //...
          }
    }
  </code></pre>
  
  <p>then override the method <code>FindView</code> and added the engine to <code>ViewEngines.Engines</code> in Global.asax, now the ViewEngine can find view pages in my defined paths.But the route still don't accept the url <code>{theme}/{controller}/{action}/{id}</code>,it seems that the route can't recognize the {theme} is the same thing with what has the same name in the engine. so I use the query string and cookie to control the theme for now,like this:</p>
  
  <pre><code>http://localhost/home?theme=black   to open  ~/themes/black/views/home/index.cshtml
  http://localhost/home?theme=white   to open  ~/themes/white/views/home/index.cshtml
  </code></pre>
  
  <p>but it's not prefect, I still need help or find the way by myself.</p>