Event HttpRequestBegin
Sets a global HTTP request listener invoked every time a request is made by the ArcGISHttpClientHandler.
Namespace: Esri.ArcGISRuntime.Http
Assembly: Esri.ArcGISRuntime.dll
Syntax
[Obsolete("Use Esri.ArcGISRuntime.Http.HttpConfigurationExtensions.UseHttpMessageInterceptor(IHttpMessageInterceptor) during the ArcGISRuntimeEnvironment.Initialize(config) call")]
public static event EventHandler<HttpRequestMessage> HttpRequestBegin
Returns
Type | Description |
---|---|
System.EventHandler<System.Net.Http.HttpRequestMessage> |
Remarks
You can use this to intercept any outgoing requests and for instance inject extra headers, append data to the query string etc, based on the request URL.
This listener is called on each and every request made by the ArcGIS Runtime, and therefore must be both thread-safe and highly performant.
Requests that implement ArcGISHttpRequestMessage provide the additional option of configuring or replacing the System.Net.Http.HttpMessageHandler that services that request.
Examples
Create a request listener that appends a header for requests to a specific domain.
ArcGISHttpClientHandler.HttpRequestBegin += (sender, request) =>
{
if (request.RequestUri.Host == "www.esri.com")
{
request.Headers.Add("X-CustomHeader", "My Custom Header");
}
};
Applies to
Target | Versions |
---|---|
.NET Standard 2.0 | 100.3 - 200.6 |
.NET | 100.13 - 200.6 |
.NET Windows | 100.13 - 200.6 |
.NET Android | 200.0 - 200.6 |
.NET iOS | 200.0 - 200.6 |
.NET Framework | 100.0 - 200.6 |
Xamarin.Android | 100.0 - 100.15 |
Xamarin.iOS | 100.0 - 100.15 |
UWP | 100.0 - 200.6 |