Skip to main content

All Questions

0 votes
0 answers
32 views

How to Resolve IWebHostEnvironment in .NET Core 8.0? [duplicate]

I'm working on migrating a project from ASP.NET Core 5.0 to .NET Core 8.0. In my project, using Test_Site_1.Application.Interfaces.Contexts; using Test_Site_1.Common.Dto; using Test_Site_1.Domain....
Amirhossein Rajaby's user avatar
0 votes
1 answer
720 views

Problem Registering services for DI in NET CORE 3

I am applying dependency injection to my dotnet 3.1 project. I created a class ServiceRegister in my Application layer: namespace Microsoft.Extensions.DependencyInjection { public static class ...
Tofetopo's user avatar
  • 486
0 votes
1 answer
774 views

.NET Core 3 dependency injection in custom validation [duplicate]

I want to make a custom validation attribute in .NET Core called CheckIfEmailExists. I want to make sure the user is not in my database already. So this is my create user view model: public class ...
SmallWorld's user avatar
5 votes
1 answer
7k views

How to inject an IServiceScope into a class in .NET Core

I have a problem with injecting Microsoft.Extensions.DependencyInjection.IServiceScope into my class. My service implementation: public class AccountService : IAccountService { private readonly ...
Adam Mrozek's user avatar
  • 1,450
14 votes
2 answers
2k views

Is there a robust way to register dependencies in ASP.NET Core 3.1 beside adding everything into Startup class?

I have an ASP.NET Core 3.1 project. Typically, I register any dependency using the ConfigureServices() method in the Startup.cs class. But, I find myself having to register lots of dependencies and ...
user avatar
7 votes
0 answers
7k views

ASP.NET Core 3.0 - Cannot access a disposed object. Object name: 'IServiceProvider'

We have windows service that hosts web api and does some calculation job in background. From time to time we get exception: 2019-12-27 11:49:15.525 +01:00 [Error] [Serilog.Log.Write] Unhandled ...
Yaroslav Ryabyi's user avatar
4 votes
1 answer
2k views

ASP.NET Core 3 - immediately instantiate a singleton after services.AddSingelton<IMySingletone, MySingletone>();

How to immediately instantiate a singleton after services.AddSingelton<IMySingleton, MySingleton>() I'm using this dirty workaround for now (call GetService in every request): public void ...
Lopuch's user avatar
  • 774
1 vote
1 answer
3k views

What is the best practice to configure httpClients in ASP Net Core 3.0 during startup?

ASP NET Core 2.1 gave us HttpClientFactory which is a great way to build custom httpClients. We used this method together with an endpoint configuration service that was injected into the constructor ...
Phillip Steele's user avatar
2 votes
1 answer
799 views

Is there any way to initialize settings model of c# on startup from the JSON settings available in the database in .net core?

I have created a web application in which I am using .net core 3.0 as server-side technology and have Postgres as backend. I have a table called settings in the database in which I am storing settings ...
Sunny's user avatar
  • 862
4 votes
4 answers
6k views

How do I auto-register/resolve services by their interface?

I'm developing a MVC .NET Core 3/Angular/Entity Framework application. My application will likely have a lot of repositories in it. To support this I would like to resolve the service (repository) by ...
Zach's user avatar
  • 3,207
0 votes
1 answer
285 views

DI Registration service type .net core 3.0

I have one n-tier layered app and in Infrastructure module where I'm trying to develop sending email for confirmation an user, I'm getting an error. No service for type 'IMS.Infrastructure....
Danijel Boksan's user avatar
1 vote
1 answer
1k views

AddSingleton - Create on run application

I need to create singletons when the application starts. In this example, I create an instance of IdentityOptions with new values. The problem is that when I start the application and I want to create ...
avechuche's user avatar
  • 1,530
10 votes
2 answers
14k views

Pass a child component as Parameter in Blazor

I would like to do in Blazor something that I normally do in React: create a reusable component that internally uses other child components, with the ability to pass those child components as ...
Franc's user avatar
  • 5,456
1 vote
1 answer
4k views

How can I inject a service into a static method in .net core

I'm writing an html helper that will do some calculations for me. Now because it is a helper it is a static method. For example: public class MyHelper { public static HtmlString DoSomething() ...
Bagzli's user avatar
  • 6,451
3 votes
0 answers
475 views

MediatR send generic type class

I've been trying to send generic type class via mediator. I created a CreateSettingCommand class that accepts any model via: var createUserCommand = new CreateSettingCommand<Database.Models....
Brown's user avatar
  • 103

15 30 50 per page