Dynamic Breadcrumbs in C# MVC5 app

I need breadcrumbs for my MVC website in this format:

<span class="inline odd first"><a href="/">Home</a></span>
<span class="delimiter">></span>
<span class="inline even"><a href="#">Link 1</a></span>
<span class="delimiter">></span>
<span class="inline odd"><a href="#">Link 2</a></span>
<span class="delimiter">></span>
<span class="inline even"><a href="#">Link 3</a></span>
<span class="delimiter">></span>
<span class="inline odd"><a href="#">Link 4</a></span>
<span class="delimiter">></span>
<span class="inline even last">You Are Here</span>

Open in new window

All the samples I've seen are using some kind of layout that uses and unordered list with list items.

This is how it needs to look:
Home > Link 1 > Link 2 > Link 3 > Link 4 > You Are Here

Open in new window


I've tried some NuGet offerings, MVCBreadCrumb, and MVCSiteMapProvider but couldn't get them to actually work in my project.

Anyone know a quick way to do this?
LVL 27
Eddie ShipmanAll-around developerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Eddie ShipmanAll-around developerAuthor Commented:
I found this and it works somewhat. I just can't get it to format the span's correctly based on the even/odd paradigm.

@Html.ActionLink("Home", "Index", "Home")
@if (ViewContext.RouteData.Values["controller"].ToString() != "Home")
{
    @Html.Raw(" > ")@Html.ActionLink(ViewContext.RouteData.Values["controller"].ToString(), "Index", ViewContext.RouteData.Values["controller"].ToString())
}
@if (ViewContext.RouteData.Values["action"].ToString() != "Index")
{
    @Html.Raw(" > ")@Html.ActionLink(ViewContext.RouteData.Values["action"].ToString(), ViewContext.RouteData.Values["action"].ToString(), ViewContext.RouteData.Values["controller"].ToString())
}

Open in new window

0
louisfrCommented:
You can add a class to an ActionLink:
@Html.ActionLink(ViewContext.RouteData.Values["controller"].ToString(), "Index", ViewContext.RouteData.Values["controller"].ToString(), new { @class = "even" })
@Html.ActionLink(ViewContext.RouteData.Values["action"].ToString(), ViewContext.RouteData.Values["action"].ToString(), ViewContext.RouteData.Values["controller"].ToString(), new { @class = "odd" })

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Eddie ShipmanAll-around developerAuthor Commented:
Not using ActionLinks.
0
louisfrCommented:
They looked like ActionLinks in your previous post.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.