My question seems to be obvious but I really don't find the solution. Well, I want to redirect to my view just after connexion. I try to use $form_state->setRedirect,but It's seems it needs the route name. I don't find the route name of my view! How to get a route name from a path? Or to redirect using the path?

  • no in this link, they say to use a route name. I don't know how to get the route name!
    – Asy
    Commented Sep 18, 2016 at 13:24
  • 3
    The route is view.[view_id].[display_id]. You find the machine name of the display in the advanced section. This is most times page_1. An example is view.frontpage.page_1 for the view of the frontpage.
    – 4uk4
    Commented Sep 18, 2016 at 15:41
  • thank you, but it doen't work I'm having this error : "Route "......" does not exist :(
    – Asy
    Commented Sep 18, 2016 at 17:33

1 Answer 1


You can also use setRedirectUrl(), which needs a URL object. There are many ways to create one, for example for an arbitrary path: Url::fromUri('base:some/path')


Not the answer you're looking for? Browse other questions tagged or ask your own question.