zHaytam / SmartBreadcrumbs

A utility library for ASP.NET Core (both MVC and Razor Pages) websites to easily add and customize breadcrumbs.
https://blog.zhaytam.com/2018/06/24/asp-net-core-using-smartbreadcrumbs/
MIT License
161 stars 77 forks source link

.Net 6 registering services syntax invalid #102

Open stephen-jonesy opened 2 years ago

stephen-jonesy commented 2 years ago

Error: InvalidOperationException: Unable to resolve service for type 'SmartBreadcrumbs.BreadcrumbManager' while attempting to activate 'SmartBreadcrumbs.BreadcrumbTagHelper'.

Since .Net 6 has moved where dependency injects are registered (from startup to Program.cs), the syntax within the documentation is no longer valid.

Is there currently a valid solution for this?

peterkhoury97 commented 2 years ago

builder.Services.AddBreadcrumbs(Assembly.GetExecutingAssembly(), options => { options.TagName = "nav"; options.TagClasses = ""; options.OlClasses = "breadcrumb"; options.LiClasses = "breadcrumb-item"; options.ActiveLiClasses = "breadcrumb-item active"; });

this will help

karenpayneoregon commented 1 year ago

In .NET Core Razor Pages I get System.InvalidOperationException: 'Sequence contains no matching element'