title: How to get MVC to lookup view in nested folder
body: <p>My knowledge of MVC and Razor is quite basic so I'm hoping its something rather simple. Basically, I have my <code>Controllers</code> as normal but my <code>Views</code> folder has a nested structure. For example, instead of:</p>
  
  <pre><code>Views -&gt; Index.cshtml
  </code></pre>
  
  <p>It is like</p>
  
  <pre><code>Views -&gt; BrandName -&gt; Index.cshtml
  </code></pre>
  
  <p>I created a custom helper to work around this, but I'm not sure how it would work with query string urls? As an example here is a controller:</p>
  
  <pre><code>    private DataService ds = new DataService();
  
      //
      // GET: /Collections/
  
      public ActionResult Index()
      {
          return View();
      }
  
  
      //
      // GET: /Collections/Collection?id=1
      public ActionResult Collection(int id)
      {
          var collectionModel = ds.GetCollection(id);
          return View(collectionModel);
      }
  </code></pre>
  
  <p>But how do I get <code>ActionResult Collection</code> to look at:</p>
  
  <pre><code>Views -&gt; Brand2 -&gt; Collection.cshtml
  </code></pre>
  
  <p>Here is the workaround method I was using:</p>
  
  <pre><code>public static string ResolvePath(string pageName)
      {
          string path = String.Empty;
          //AppSetting Key=Brand
          string brand = ConfigurationManager.AppSettings["Brand"];
  
          if (String.IsNullOrWhiteSpace(brand))
              path = "~/Views/Shared/Error.cshtml"; //Key [Brand] was not specified
          else
              path = String.Format("~/Views/{0}/{1}", brand, pageName);
  
          return path;
      }
  </code></pre>