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

Fix IActionContextAccessor DI registration #4

Closed askalione closed 6 years ago

askalione commented 6 years ago

Hello!

I'm using your utility-library with latest Asp.Net Core 2.1 and get fatal error all time when start application. The problem with register IActionContextAccessor:

InvalidOperationException: Cannot consume scoped service 'Microsoft.AspNetCore.Mvc.Infrastructure.IActionContextAccessor'.

Because IActionContextAccessor should be resolving as Singleton like IHttpContextAccessor. Look this commit for services.AddHttpContextAccessor() method.

So it should be services.TryAddSingleton<IActionContextAccessor, ActionContextAccessor>();

zHaytam commented 6 years ago

Thank you for the PR, I merged it and will update the NuGet package now.