SmartBreadcrumbs: Index breadcrumb always shows, even if user did not access that page

My DefaultBreadcrumb is “Home”. So let’s say on my MVC home page, the user can navigate to two different links.

<a href="/Contact/Index">Index</a>
<a href="/Contact/Edit?contactId=##">Edit</a>

One goes to controller/action Contact/Index and one goes to Contact/Edit. I have a breadcrumb attribute for both in the ContactController. When the user navigates to Contact/Index, the breadcrumbs correctly looks like:

Home / Index

When the user navigates to Contact/Edit, the breadcrumbs incorrectly looks like:

Home / Index / Edit

The user should not be able to navigate back to Index on this breadcrumb, only to Home.
It should look like this:

Home / Edit

Is this a bug?

Thanks! Bryan

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 29 (7 by maintainers)

Most upvoted comments

Good news @bryancass @timstokman, I fixed both your issues!
Indeed the problem was that commit you pointed at, which added some “forced” functionnality.

In order to fix the issues, I added two options:

  • InferFromAction: A boolean, if set to true (which it is by default), it will set FromAction to the DefaultAction option when no FromX is specified.
  • FallbackTitleToMethodName: A boolean, if set to true (which it is by default), it will use the method’s name when no title was set.

You will need to set these options to false so that you get the behavior you want.
The NuGet version with this fix is 3.1.1.

I tried it on my production web app and it doesn’t work correctly. All you get is the default breadcrumb and the page you are on. It’s missing all the pages in between the Home page and how you got to the page you’re on.

@bryancass If I get what you’re saying, yes. What changed since version 2.1 of this library is that it links to “Index” as a previous action in the breadcrumb trail (FromAction in [Breadcrumb…) if there’s no previous action. My workaround (I hope) will restore the previous behaviour (end of the trail if there’s no FromAction), until there’s an actual fix.