Clients¶
C# Api Clients¶
C# proxies automatically handle the following stuff for you;
- Maps C# method calls to remote server HTTP calls by considering the HTTP method, route, query string parameters, request payload and other details.
- **Authenticates the HTTP Client by adding access token to the HTTP header.
- Serializes to and deserialize from JSON.
- Handles HTTP API versioning.
- Add correlation id, current tenant id and the current culture to the request.
- Properly handles the error messages sent by the server and throws proper exceptions.
This system can be used by any type of .NET client to consume your HTTP APIs.
Static vs Dynamic C# Client Proxies¶
ABP provides two types of client proxy generation system:
-
Dynamic C# Client Proxy
-
Static C# Client Proxy
Development-time (static) client proxy generation has a slight performance advantage since it doesn't need to obtain the HTTP API definition on runtime. However, you should re-generate the client proxy code whenever you change your API endpoint definition.
On the other hand, dynamic client proxies are generated on runtime and provides an easier development experience.
Static Client Proxy¶
Your service/controller should implement an interface that is shared between the server and the client. So, first define a service interface in a shared library project, typically in the Application.Contracts
project.
public interface IIdentityUserAppService : IApplicationService
{
Task<IdentityUserDto> CreateAsync(CreateIdentityUserInput input);
}