How to get current route in the midst of a Views AJAX request
use Symfony\Component\HttpFoundation\Request;

if (\Drupal::routeMatch()-&gt;getRouteName() == 'views.ajax') {
    $previousUrl = \Drupal::request()-&gt;server-&gt;get('HTTP_REFERER');
    $fake_request = Request::create($previousUrl);
    $url_object = \Drupal::service('path.validator')-&gt;getUrlIfValid($fake_request-&gt;getRequestUri());
    if ($url_object) {
      $route_name = $url_object-&gt;getRouteName();
      // Do something with $route_name;
    }
  }