N
N
Nik Faraday2022-01-18 16:51:14
ASP.NET
Nik Faraday, 2022-01-18 16:51:14

How to create a service for asp.net core authentication?

Hello
To pass authentication, you need to throw the appropriate logic into the services, but I have a problem, which is that I don’t know how to do it.
The problem is built around the IHttpContext object. Since the service is a pure C# library, there are no corresponding objects there. Loading the corresponding NuGet package is stupid, because the service library has many other service classes for various kinds of tasks, and loading the library with this is stupid.
What rational options can there be in this regard and how to solve this problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2022-01-18
@NikFaraday

Loading the corresponding NuGet package is stupid, because the service library has many other service classes for various kinds of tasks, and loading the library with this is stupid.

Why stupid?
Silly - it's a lot of different service classes for different tasks to be combined within the same library.
If you need something from aspnetcore, then you need to make the library dependent on it.
https://docs.microsoft.com/en-us/aspnet/core/funda...
Prior to .netcore 3.1, you could use Nuget with abstractions (Microsoft.AspNetCore.Http and Microsoft.AspNetCore.Http.Abstractions), but now aspnet comes with runtime, so you need to do FrameworkReference

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question