1.2Installation & Service Registration

Created on Aug 17, 2026~6 min read

Before making HTTP remote requests, you need to register and configure the HttpRemote service in the Startup.cs or Program.cs file.

cs
// Register in Startup.cs:services.AddHttpRemote();// In Program.cs, register as follows:// builder.Services.AddHttpRemote();

Then, inject the IHttpRemoteService service into your services, controllers, or any class that supports dependency injection.

cs
public class YourService{    private readonly IHttpRemoteService _httpRemoteService;    public YourService(IHttpRemoteService httpRemoteService)    {        _httpRemoteService = httpRemoteService;    }}

If you are using .NET 8 or later, you can simplify the code by injecting via primary constructor:

cs
public class YourService(IHttpRemoteService httpRemoteService){    // Use the httpRemoteService variable}

Alternatively, you can also inject it on demand in a specific method:

cs
public class YourService{    public Task<string> GetResource([FromServices] IHttpRemoteService httpRemoteService)    {        // Your code logic here    }}