Questions tagged [routes]

Questions about mapping URLs to Controllers and Actions.

MVC web application (like Ruby on Rails, ASP.NET MVC, etc) uses routes to map an arbitrary URL to a specific controller/action.

For example

http://example.com/foo/bar/23

Might pass an id 23 to controller foo, action bar.

Unusual URLs could also be mapped

Given controller places and intended action list, we can use routes to allow this URL:

http://example.com/my/places
32975 questions
75
votes
6 answers

Multiple canActivate guards all run when first fails

I have a route with two canActivate guards (AuthGuard and RoleGuard). The first (AuthGuard) checks to see if the user is logged in and, if not, redirects to the login page. The second checks to see if the user has a role defined that is allowed to…
revoxover
  • 965
  • 1
  • 7
  • 10
74
votes
8 answers

No provider for Router?

Im getting this error: EXCEPTION: Error in ./AppComponent class AppComponent - inline template:0:0 caused by: No provider for Router! This is my app component: import {Component} from '@angular/core'; import {LoginComponent} from…
None
  • 8,817
  • 26
  • 96
  • 171
73
votes
3 answers

Akka Actor not terminating if an exception is thrown

I am currently trying to get started with Akka and I am facing a weird problem. I've got the following code for my Actor: class AkkaWorkerFT extends Actor { def receive = { case Work(n, c) if n < 0 => throw new Exception("Negative number") …
fresskoma
  • 25,481
  • 10
  • 85
  • 128
73
votes
7 answers

What is the difference between _url and _path while using the routes in rails

When we define routes in routes.rb using the name like map.some_link.We can use the link in two ways- some_link_url, some_link_path. What are the differences between the two? Which is more secure to be used?
MohamedSanaulla
  • 6,112
  • 5
  • 28
  • 45
73
votes
19 answers

Laravel 4 All Routes Except Home Result in 404 Error

I installed Laravel 4 using Composer and also set up a virtual host. Currently, only the root route is working:
Amit Erandole
  • 11,995
  • 23
  • 65
  • 103
72
votes
4 answers

How to get the _locale variable inside in a Symfony layout?

I'm working with Symfony 2 on a site which having 2 languages, and I want to change patterns of my routes depending on user locale language ! Example: user_login_en: pattern: /en/user/login.html defaults: { _controller:…
Sybio
  • 8,565
  • 3
  • 44
  • 53
72
votes
15 answers

How to smooth scroll to page anchor in angular 4 without plugins properly?

What I want to achieve is a click to and do a smooth scroll to bottom / specified div area which i define with hashtag just like i think it should be like this. here is the live example in the w3school example which is written for JQuery:…
Ke Vin
  • 3,478
  • 11
  • 60
  • 91
72
votes
1 answer

How can I set a query parameter in AngularJS without doing a route?

My Angular app allows the user to load an item, and when that happens I'd like to set a query string that contains the item's Id so that if the user refreshes the page (or wants to link to it), the URL is already set (there's already code in place…
Mike Pateras
  • 14,715
  • 30
  • 97
  • 137
72
votes
10 answers

How to use absolute path in twig functions

I have an application with Symfony2 (2.2). When I want to send a mail, I'm having trouble with the paths, which are all relative paths and obviously aren't working inside emails for rendering the paths I'm using:
rkmax
  • 17,633
  • 23
  • 91
  • 176
72
votes
7 answers

ASP.NET MVC, Url Routing: Maximum Path (URL) Length

The Scenario I have an application where we took the good old query string URL structure: ?x=1&y=2&z=3&a=4&b=5&c=6 and changed it into a path structure: /x/1/y/2/z/3/a/4/b/5/c/6 We're using ASP.NET MVC and (naturally) ASP.NET routing. The…
Martin Suchanek
  • 3,006
  • 6
  • 31
  • 31
71
votes
1 answer

Routing with an optional parameter

I added in the route file: map.show_book "/show_book/:name/year/:year", :controller => "book", :action => "show_version" I also added: map.show_book "/show_book/:name", :controller => "book", :action => "show_version" to show the latest book…
71
votes
1 answer

When user is not logged in redirect to login. Reactjs

My App looks like: class App extends Component { render() {
Ivan Hreskiv
  • 1,045
  • 1
  • 11
  • 18
71
votes
3 answers

Express routes parameter conditions

I have a route on my Express app that looks like this: app.get('/:id', function (request, response) { … }); The ID will always be a number. However, at the moment this route is matching other things, such as /login. I think I want two things…
user1082754
70
votes
2 answers

Dynamic Routes from database for ASP.NET MVC CMS

Basically I have a CMS backend I built using ASP.NET MVC and now I'm moving on to the frontend site and need to be able to load pages from my CMS database, based on the route entered. So if the user enters example.com/students/information, MVC would…
Carl Weis
  • 6,794
  • 15
  • 63
  • 86
69
votes
4 answers

A YAML file cannot contain tabs as indentation

This is my first work with Symfony 2. All I am trying to do here is whenever the user clicks on the submit button he will go to another page. But my index page isn't loading. They are saying there is something wrong with my routing file,…
odbhut.shei.chhele
  • 5,834
  • 16
  • 69
  • 109