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
public static event EventHandler<HttpRequestMessage> HttpRequestBegin
Returns
Type | Description |
---|---|
System.EventHandler<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 - 100.15 |
.NET 6.0 | 100.13 - 100.15 |
.NET 6.0 Windows | 100.13 - 100.15 |
.NET Framework | 100.0 - 100.15 |
.NET 5 | 100.10 - 100.12 |
.NET Core 3.1 | 100.7 - 100.12 |
Xamarin.Android | 100.0 - 100.15 |
Xamarin.iOS | 100.0 - 100.15 |
UWP | 100.0 - 100.15 |