I am using the code below to display a breadcrumb on my site and it works perfectly, but what I’m trying to work out is how to change the action name that’s being used to a name with spaces.
@if (ViewContext.RouteData.Values["controller"].ToString() == "Home")
{
@Html.Label(ViewContext.RouteData.Values["controller"].ToString(), ViewContext.RouteData.Values["controller"].ToString(), ViewContext.RouteData.Values["controller"].ToString())
}
@if (ViewContext.RouteData.Values["controller"].ToString() != "Home")
{
@:Home > @Html.Label(ViewContext.RouteData.Values["controller"].ToString(), ViewContext.RouteData.Values["controller"].ToString(), ViewContext.RouteData.Values["controller"].ToString())
if (ViewContext.RouteData.Values["action"].ToString() != "Index")
{
@:> @Html.Label(ViewContext.RouteData.Values["action"].ToString(), ViewContext.RouteData.Values["action"].ToString(), ViewContext.RouteData.Values["controller"].ToString())
}
}
So for example I have a Controller as below:
namespace CristalStandards.Controllers
{
public class ClaimsController : Controller
{
//
// GET: /Claims/
public ActionResult Index()
{
return View();
}
//
// GET: /Claims/Diligence/
public ActionResult Diligence()
{
return View();
}
}
}
Which then creates a breadcrumb like this:
Home > claims > diligence
But what I would like to have is a breadcrumb like this
Home > claims management > claims and due diligence
So where can I insert ‘claims management’ and ‘claims and due diligence’ into the controller and then use those names in the breadcrumb script at the top of this post, without it affecting anything else.