In software development, a proxy acts as an intermediary to control access to a feature or resource. A proxy can implement features such as permission checks, operation logs, data caching, and lazy loading without changing the original code. This makes a program more secure, faster, and easier to maintain and extend. This topic describes how to configure a proxy for the .NET software development kit (SDK) V2.0.
Proxy types
HTTP and HTTPS proxies are supported. You can use either type in your application.
Proxy type | Description |
HTTP proxy | Configure the proxy server address and port using the HttpProxy parameter. The format is |
HTTPS proxy | Configure the proxy server address and port using the HttpsProxy parameter. The format is |
If the proxy server requires authentication, add the username and password to the address. The format is http://<user>:<password>@<IP address>:<port>.
Proxy configuration methods
The proxy configurations take effect in the following descending order: the configuration using the RuntimeOptions object and the configuration when you initialize an SDK client.
You can configure a proxy for the current request using
AlibabaCloud.TeaUtil.Models.RuntimeOptions.// Runtime parameter settings. These settings apply only to requests that use this RuntimeOptions instance. var runtimeOptions = new AlibabaCloud.TeaUtil.Models.RuntimeOptions { HttpProxy = "http://127.0.0.1:9898"; HttpsProxy = "http://127.0.0.1:8989"; };You can configure a proxy for all requests using
AlibabaCloud.OpenApiClient.Models.Config.var config = new AlibabaCloud.OpenApiClient.Models.Config { // Proxy parameter settings. These settings apply to all clients that use this config. HttpProxy = "http://127.0.0.1:9898", HttpsProxy = "http://127.0.0.1:8989" };
References
For more information about how to configure an HTTP proxy, see HTTP proxy configuration.