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
31
votes
2 answers

How do I do geocoding and routing with OpenStreetMap?

Because Google Maps API is not available in Israel (see here) I want to use OpenStreetMap. I'm confused by all the different ways to do geocoding, i.e. finding lat,long for an address. I'm also looking for the best way to do routing, i.e. display a…
GilShalit
  • 6,175
  • 9
  • 47
  • 68
31
votes
2 answers

Redirect from one Area's action to a action in the "root"-area?

I use the latest version of ASP.Net MVC 2 RC. My question is, how do I redirect from one action that's in the "Blog"-area to the index-action in the home-controller that exists in the "root" of my application (no area)? I tried: return…
Mickel
  • 6,658
  • 5
  • 42
  • 59
30
votes
2 answers

routes in rails - removing actions when setting up a resource

I've setup a simple app and added a scaffold to do some of the work for me (I'm a noob). resources :cars How do I remove certain actions from the routes? And remove the corresponding urls? For example I want to keep the 'show' and 'edit' actions…
Finnnn
  • 3,530
  • 6
  • 46
  • 69
30
votes
2 answers

How to use "useRouter()" from next.js in a class component?

I was trying to get the queries from my url pattern like localhost:3000/post?loc=100 by using useRouter() from "next/router" and fetching some data using that id from my server. It worked when I used it in a Stateless Functional Component. But the…
Shakirul Hasan
  • 678
  • 1
  • 5
  • 14
30
votes
1 answer

Flask middleware for specific route

I made API Server with Python Flask-RESTful. My system use token authentication for verify permission. So, I added middleware for verify token. For example, code like this, [middleware.py] class Test(object): def __init__(self, app): …
Hide
  • 3,199
  • 7
  • 41
  • 83
30
votes
5 answers

How can I redirect a user's home (root) path based on their role using Devise?

I'm working on a project management app, and in the app, I have project_managers and clients. I'm using Devise and CanCan for authentication/authorization. At what point after login should I be redirecting the user to their own specific…
Mark
  • 315
  • 1
  • 4
  • 5
30
votes
5 answers

redirect to 404 page automatically at laravel 5.4

i made simple resume site with laravel 5.4 and i wanna if users type anything except my site name and my site.com/panel automatically redirect to 404 page. how can i do that? is there any route to do that or what? i found this code but not use …
Siros Fakhri
  • 2,133
  • 5
  • 20
  • 31
30
votes
8 answers

React Router Redirect drops param

I am using the next version of React Router, and it seems to be dropping params. I expect the redirect below to retain the value of channelId, but the to route uses the literal string ":channelId" in the path instead.
Matt Norris
  • 8,596
  • 14
  • 59
  • 90
30
votes
2 answers

Angular 2 feature module routing example

As far as Angular 2 routing goes, I've mostly been able to find examples of the scenario where there's exactly one routing file for the whole application. I'd like to see an example of using not just one routing file, but a main routing file and…
Jason Swett
  • 43,526
  • 67
  • 220
  • 351
30
votes
4 answers

Angular 2 Activatedroute params not working in Service or outside

I have a very strange problem: index.html
Cabe Skuriles
  • 514
  • 1
  • 9
  • 18
30
votes
2 answers

How to get RouteData by URL?

I need to get RoutData by given URL string in ASP.NET MVC application. I've found the way that I need to mock HttpContextBase based on my URL string and then pass it to RouteTable.Routes.GetRouteData() method in Route Parsing (Uri to Route)…
Serge S.
  • 4,855
  • 3
  • 42
  • 46
29
votes
1 answer

Redirect (301) one route to another from routing.yml in Symfony2

I know this is probably trivial, but I couldn't find anything on the web or in the Symfony2 reference. How do I redirect one route to another from routing.yml (with 301 status code)? I'm looking for something like this: SomeRoute: pattern:…
lemon24
  • 329
  • 1
  • 3
  • 6
29
votes
4 answers

How can I access a service running on WSL2 from inside a Docker container?

I am using Windows 10 1909 and have installed WSL2, using Ubuntu 20.04, the 19.03.13-beta2 docker version, having installed Docker for Windows Edge version using the WSL2 option. The integration is working pretty great, but I have one issue which I…
donmartin
  • 1,753
  • 2
  • 15
  • 30
29
votes
6 answers

Angular router url returns slash

I'm trying to get the current router path by using Router, but when i do console.log(this.router.url) it returns "/", although i'm on the "/login". But when i'm consoling the entire this.router object, there is the property url which has value…
sandum
  • 751
  • 5
  • 13
  • 25
29
votes
2 answers

Angular 2, RC5 router-outlet inside another router-outlet

I'm trying to make one project with one router-outlet inside another router-outlet: It will work like this: In the first router-outlet it will have two views: auth component (/login) admin component (/admin) Then in the second outlet will be…
Thiago Yoithi
  • 495
  • 1
  • 6
  • 13