Show / Hide Table of Contents

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
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 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

TargetVersions
.NET Standard 2.0100.3 - 100.14
.NET 6.0100.13 - 100.14
.NET 6.0 Windows100.13 - 100.14
.NET Framework100.0 - 100.14
.NET 5100.10 - 100.12
.NET Core 3.1100.7 - 100.12
Xamarin.Android100.0 - 100.14
Xamarin.iOS100.0 - 100.14
UWP100.0 - 100.14
In This Article
Back to top Copyright © 2021 Esri.