I am working on an web application (.net core 5) and trying to replace a singleton dependency. I know, it is possible to replace dependency inside Startup.cs
(ConfigureServices(IServiceCollection services) method)
. But problem is I cant access "IServiceCollection " in controller. Do you guys have an idea how to achive it?
It seems this work for replacing dependency, But the problem is I dont have access to services in controller: Replace service registration in ASP.NET Core built-in DI container?
I red this, but the answer does not works: .NET Core - Changing dependency in Controller
UPDATE :
Scenario : I am developing a insta API app with InstaSharper first time user want to use this web app, my instaAPI service implementation stores null username and password for this service. Now user is going to add instagram username and password. Now I need to reset instaAPI service and set new username and password. this can be happen every time user update his/her username or password.