title: Minimal way to handle static content routes/controllers/views from data driven menus?
body: <p>I have a ListItem class that is used to represent menu items in my application:</p>
  
  <pre><code> public class ListItem : Entity
  {
      public virtual List List { get; set; }
      public virtual ListItem ParentItem { get; set; }
      public virtual ICollection&lt;ListItem&gt; ChildItems { get; set; }
  
      public int SortOrder { get; set; }
      public string Text { get; set; }
      public string Controller { get; set; }
      public string Action { get; set; }
      public string Area { get; set; }
      public string Url { get; set; }
  }
  </code></pre>
  
  <p>I use this data to construct the routes for the application, but I was wondering if there was a clean way to handle controller/views for static content? Basically any page that doesn't use any data but just views. Right now I have one controller called StaticContentController, which contains a unique action for each static page that returns the appropriate view like so:</p>
  
  <pre><code>public class StaticContentController : Controller
  {
  
      public ActionResult Books()
      {
          return View("~/Views/Books/Index.cshtml");
      }
  
      public ActionResult BookCategories()
      {
          return View("~/Views/Books/Categories.cshtml");
      }
  
      public ActionResult BookCategoriesSearch()
      {
          return View("~/Views/Books/Categories/Search.cshtml");
      }
  }
  </code></pre>
  
  <p>Is there some way I could minimize this so I don't have to have so many controllers/actions for static content? It seems like when creating my ListItem data I could set the Controller to a specific controller that handles static content, like I have done, but is there anyway to use one function to calculate what View to return? It seems like I still need separate actions otherwise I won't know what page the user was trying to get to. </p>
  
  <p>The ListItem.Url contains the full URL path from the application root used in creating the route. The location of the View in the project would correspond to the URL location to keep the organization structure parallel.</p>
  
  <p>Any suggestions? Thanks.</p>
  
  <p>Edit: My Route registration looks like so:</p>
  
  <pre><code>public static void RegisterRoutes(RouteCollection routes)
      {
          routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
          routes.IgnoreRoute("Shared/{*pathInfo}");
          routes.MapRoute("Access Denied", "AccessDenied", new { controller = "Shared", action = "AccessDenied", area = "" });
          List&lt;ListItem&gt; listItems = EntityServiceFactory.GetService&lt;ListItemService&gt;().GetAllListItmes();
          foreach (ListItem item in listItems.Where(item =&gt; item.Text != null &amp;&amp; item.Url != null &amp;&amp; item.Controller != null).OrderBy(x =&gt; x.Url))
          {
              RouteTable.Routes.MapRoute(item.Text + listItems.FindIndex(x =&gt; x == item), item.Url.StartsWith("/") ? item.Url.Remove(0, 1) : item.Url, new { controller = item.Controller, action = item.Action ?? "index" });
          }
  
          routes.MapRoute(
              "Default", // Route name
              "{controller}/{action}/{id}", // URL with parameters
              new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
          );
  
  
      }
  </code></pre>