I'm working on a website (MVC dotnetcore)
that has many pages and flows as well. A user can approach a single page from many different ways. I'm getting stuck when user wants to move back and I don't have any track of its last URL. And I'm getting confused that how to handle this situation?
Should I use a global variable to keep track of last URL??
but in this case, I've to do a repeatable code on each screen, or may be for each get/ post call.
OR
Should I use kind of breadcrumbs structure?
Like if user move Admin from Index, there would be something like this
Index >> Admin
And for further
Index >> Admin >> ManageUsers
And these would be links to their related pages. But I dont know how to handle this in mvc dotnetcore? Any Idea??
Which approach is good to follow? Any kind of help will be appreciated.
I know the answer is a bit old, but I got the same problem when I was creating websites. I didn't want to repeat code in both projects and I wanted the breadcrumbs to handle multiple levels, especially levels that aren't in the same Controller. I ended up creating a little package to manage all of this: SmartBreadcrumbs (available in Nuget).
It's very easy to use, all you need to do is:
services.UseBreadcrumbs(GetType().Assembly);
[DefaultBreadcrumb("My home")]
to your default node (usually the Home)[Breadcrumb("Contact me", FromAction = "Index" FromController = typeof(HomeController))]
to your other levels (FromAction can be any combination of Controller.Action)PS: The default node is ALWAYS present, even without specifying FromAction
.
More informations on the github link or Blog post.
EDIT: Updated examples for version 2.0.0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With