Using ResourceHandler you can also intercept and handle AJAX requests and determine whether this request should be executed or not. To this, you need to register your own ResourceHandler implementation. For example:

C#

private class TestResourceHandler : ResourceHandler
{
    public bool CanLoadResource(ResourceParams parameters)
    {
        if (parameters.ResourceType == ResourceType.XHR)
        {
            Console.WriteLine("Suppress ajax call - " + parameters.URL);
            return false;
        }
        return true;
    }
}

VB.NET

Private Class TestResourceHandler
    Implements ResourceHandler

    Public Function CanLoadResource(ByVal parameters As ResourceParams) As Boolean _
        Implements ResourceHandler.CanLoadResource
        If parameters.ResourceType = ResourceType.XHR Then
            Console.WriteLine("Suppress ajax call - " & parameters.URL)
            Return False
        End If

        Return True
    End Function
End Class


This resource handler is attached to the network service of the corresponding browser context:

C#

browser.Context.NetworkService.ResourceHandler = new TestResourceHandler();

VB.NET

browser.Context.NetworkService.ResourceHandler = New TestResourceHandler()


Using the parameters variable, you can obtain the request URL and method. If CanLoadResource() returns false, the request will be cancelled.