title: Breadcrumbs in C# MVC Website using Bootstrap
body: <p>I'm looking to add breadcrumbs to my site, but I'm not quite sure how to go about it. I have been able to get something basic working with the following code:</p>
  
  <pre><code>&lt;ol class="breadcrumb"&gt;
      &lt;li class="active"&gt;
          @Html.ActionLink("Home", "Index", "Home")
          @if (ViewContext.RouteData.Values["controller"] != "Home" &amp;&amp; ViewContext.RouteData.Values["action"] != "Index")
          {
              @:&gt; @Html.ActionLink(ViewContext.RouteData.Values["controller"].ToString(), "Index", ViewContext.RouteData.Values["controller"].ToString())
          }
  
          &gt; @ViewBag.SubTitle
      &lt;/li&gt;
  &lt;/ol&gt;
  </code></pre>
  
  <p>The problem I have though is that this doesn't actually track your history, it just shows you</p>
  
  <pre><code>Home &gt; ControllerName &gt; CurrentItem
  </code></pre>
  
  <p>e.g.</p>
  
  <pre><code>Home &gt; Members &gt; Greg Dodd
  </code></pre>
  
  <p>This works well when you've come from a member search page, however if you come from a different page then you lose that history. How do you create a breadcrumb trail using History in MVC?</p>
  
  <p>I guess what I'm looking for is something like:</p>
  
  <pre><code>Home &gt; Controller1 &gt; PreviousItem &gt; ... &gt; CurrentItem
  </code></pre>
  
  <p>e.g.
  If you opened up a blog, then a particular blog item, then clicked the authors name, your breadcrumbs should be:</p>
  
  <pre><code>Home &gt; Blog &gt; SomeBlogTitle &gt; AuthorName
  </code></pre>
  
  <p>If however you opened a list of authors and then chose a particular author, you would see the same view rendered using the same controller, but the breadcrumbs should show:</p>
  
  <pre><code>Home &gt; Authors &gt; AuthorName
  </code></pre>