Skip to main content

Questions tagged [routes]

Questions about mapping URLs to Controllers and Actions.

Filter by
Sorted by
Tagged with
680 votes
31 answers
755k views

How to detect a route change in Angular?

I am looking to detect a route change in my AppComponent. Thereafter I will check the global user token to see if the user is logged in so that I can redirect the user if the user is not logged in.
AngularM's user avatar
  • 16.5k
398 votes
31 answers
142k views

No route matches "/users/sign_out" devise rails 3

I've installed devise on my app and applied the following in my application.html.erb file: <div id="user_nav"> <% if user_signed_in? %> Signed in as <%= current_user.email %...
vich's user avatar
  • 11.9k
386 votes
10 answers
602k views

Send data through routing paths in Angular

Is there anyway to send data as parameter with router.navigate? I mean, something like this example, as you can see the route has a data parameter, but doing this it's not working: this.router....
Motomine's user avatar
  • 4,414
338 votes
18 answers
182k views

S3 Static Website Hosting Route All Paths to Index.html

I am using S3 to host a javascript app that will use HTML5 pushStates. The problem is if the user bookmarks any of the URLs, it will not resolve to anything. What I need is the ability to take all url ...
Mark Nutter's user avatar
  • 5,579
256 votes
9 answers
423k views

A potentially dangerous Request.Path value was detected from the client (*)

I am receiving the rather self explanatory error: A potentially dangerous Request.Path value was detected from the client (*). The issue is due to * in the request URL: https://stackoverflow.com/...
user avatar
249 votes
14 answers
229k views

How can I find out the current route in Rails?

I need to know the current route in a filter in Rails. How can I find out what it is? I'm doing REST resources, and see no named routes.
luca's user avatar
  • 12.6k
249 votes
13 answers
229k views

How to get current route in Symfony 2?

How do I get the current route in Symfony 2? For example, routing.yml: somePage: pattern: /page/ defaults: { _controller: "AcmeBundle:Test:index" } How can I get this somePage value?
IlyaDoroshin's user avatar
  • 4,669
245 votes
8 answers
363k views

How/when to use ng-click to call a route?

Suppose you are using routes: // bootstrap myApp.config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) { $routeProvider.when('/home', { templateUrl: ...
Robert Christian's user avatar
244 votes
10 answers
81k views

Is it possible to make an ASP.NET MVC route based on a subdomain?

Is it possible to have an ASP.NET MVC route that uses subdomain information to determine its route? For example: user1.domain.example goes to one place user2.domain.example goes to another? Or, can ...
Dan Esparza's user avatar
  • 28.3k
230 votes
8 answers
214k views

Angular 2 router no base href set

I am getting an error and can't find why. Here is the error: EXCEPTION: Error during instantiation of LocationStrategy! (RouterOutlet -> Router -> Location -> LocationStrategy). angular2....
Jason Spick's user avatar
  • 6,088
229 votes
11 answers
401k views

How to open a link in new tab using angular?

I have an angular 5 component that needs to open a link in new tab, I tried the following: <a href="www.example.com" target="_blank">page link</a> when I open the link, the application ...
AlejoDev's user avatar
  • 4,622
216 votes
3 answers
173k views

Failed to instantiate module [$injector:unpr] Unknown provider: $routeProvider

I received this error upon upgrading from AngularJS 1.0.7 to 1.2.0rc1.
Scotty.NET's user avatar
  • 12.5k
205 votes
21 answers
634k views

Next.js Redirect from / to another page

I'm new in Next.js and I'm wondering how to redirect from start page ( / ) to /hello-nextjs for example. Once user loads a page and after that determine if path === / redirect to /hello-nextjs In ...
Arthur's user avatar
  • 3,416
198 votes
14 answers
271k views

Change route params without reloading in Angular 2

I'm making a real estate website using Angular 2, Google Maps, etc. and when a user changes the center of the map I perform a search to the API indicating the current position of the map as well as ...
Marcos Basualdo's user avatar
195 votes
18 answers
265k views

Passive Link in Angular 2 - <a href=""> equivalent

In Angular 1.x I can do the following to create a link which does basically nothing: <a href="">My Link</a> But the same tag navigates to the app base in Angular 2. What is the ...
s.alem's user avatar
  • 13k
183 votes
4 answers
271k views

Laravel - Route::resource vs Route::controller

I read the docs on the Laravel website, Stack Overflow, and Google but still don't understand the difference between Route::resource and Route::controller. One of the answers said Route::resource ...
Sonique's user avatar
  • 6,930
179 votes
6 answers
168k views

Rails 3: I want to list all paths defined in my rails application

I want to list all defined helper path functions (that are created from routes) in my rails 3 application, if that is possible. Thanks,
wael34218's user avatar
  • 4,890
167 votes
4 answers
239k views

Difference between [routerLink] and routerLink

What is the difference between [routerLink] and routerLink ? How should you use each one?
Eslam Tahoon's user avatar
  • 2,263
165 votes
21 answers
168k views

Angular2 Routing with Hashtag to page anchor

I wish to add some links on my Angular2 page, that when click, will jump to specific positions within that page, like what normal hashtags do. So the links would be something like /users/123#userInfo ...
Stone's user avatar
  • 1,901
162 votes
25 answers
731k views

How to Refresh a Component in Angular

I am working on an Angular project. I'm struggling with refresh action in a component. I would like to refresh the router's components on button click. I have refresh button when I click on it the ...
Sreehari Ballampalli's user avatar
155 votes
8 answers
61k views

How can I have lowercase routes in ASP.NET MVC?

How can I have lowercase, plus underscore if possible, routes in ASP.NET MVC? So that I would have /dinners/details/2 call DinnersController.Details(2) and, if possible, /dinners/more_details/2 call ...
153 votes
5 answers
135k views

express.js - single routing handler for multiple routes in a single line

Is there a way to make this on a single function call? var todo = function (req, res){}; app.get("/", todo); app.get("/blabla", todo); app.get("/blablablabla", todo); Something like: app.get("/", "...
Aronis Mariano's user avatar
153 votes
15 answers
61k views

How do I remove the Devise route to sign up?

I'm using Devise in a Rails 3 app, but in this case, a user must be created by an existing user, who determines what permissions he/she will have. Because of this, I want: To remove the route for ...
Nathan Long's user avatar
152 votes
8 answers
155k views

Redirect From Action Filter Attribute

What is the best way to do a redirect in an ActionFilterAttribute. I have an ActionFilterAttribute called IsAuthenticatedAttributeFilter and that checked the value of a session variable. If the ...
ryanzec's user avatar
  • 27.8k
151 votes
7 answers
39k views

API Versioning for Rails Routes

I'm trying to version my API like Stripe has. Below is given the latest API version is 2. /api/users returns a 301 to /api/v2/users /api/v1/users returns a 200 of users index at version 1 /api/v3/...
maletor's user avatar
  • 7,112
147 votes
16 answers
161k views

Add a prefix to all Flask routes

I have a prefix that I want to add to every route. Right now I add a constant to the route at every definition. Is there a way to do this automatically? PREFIX = "/abc/123" @app.route(PREFIX + "/")...
Evan Hahn's user avatar
  • 12.5k
147 votes
3 answers
351k views

Routing with Multiple Parameters using ASP.NET MVC

Our company is developing an API for our products and we are thinking about using ASP.NET MVC. While designing our API, we decided to use calls like the one below for the user to request information ...
CodingWithoutComments's user avatar
145 votes
19 answers
254k views

How to set the DefaultRoute to another Route in React Router

I have the following: <Route name="app" path="/" handler={App}> <Route name="dashboards" path="dashboards" handler={Dashboard}> <Route name="exploreDashboard" path="...
Matthew Herbst's user avatar
142 votes
5 answers
275k views

How to get default gateway in Mac OSX

I need to retrieve the default gateway on a Mac machine. I know that in Linux route -n will give an output from which I can easily retrieve this information. However this is not working in Mac OSX(...
SherinThomas's user avatar
  • 1,951
134 votes
10 answers
174k views

How do I redirect to the previous action in ASP.NET MVC?

Lets suppose that I have some pages some.web/articles/details/5 some.web/users/info/bob some.web/foo/bar/7 that can call a common utility controller like locale/change/es or authorization/login ...
adolfojp's user avatar
  • 2,991
121 votes
8 answers
143k views

Use specific middleware in Express for all paths except a specific one

I am using the Express framework in node.js with some middleware functions: var app = express.createServer(options); app.use(User.checkUser); I can use the .use function with an additional parameter ...
Thomas's user avatar
  • 10.5k
120 votes
2 answers
144k views

Passing route control with optional parameter after root in express?

I'm working on a simple url-shortening app and have the following express routes: app.get('/', function(req, res){ res.render('index', { link: null }); }); app.post('/', function(req, res){ ...
Qcom's user avatar
  • 18.9k
118 votes
20 answers
346k views

How to force Laravel Project to use HTTPS for all routes?

I am working on a project that requires a secure connection. I can set the route, uri, asset to use 'https' via: Route::get('order/details/{id}', ['uses' => 'OrderController@details', 'as' => '...
Nelson Melecio's user avatar
117 votes
2 answers
80k views

Client Routing (using react-router) and Server-Side Routing

I have been thinking and I am confused with the routing between Client and Server. Suppose I use ReactJS for server-side rendering before sending the request back to web browser, and use react-router ...
heartmon's user avatar
  • 1,421
116 votes
11 answers
81k views

React-router v4 - cannot GET *url*

I started to use react-router v4. I have a simple <Router> in my app.js with some navigation links (see code below). If I navigate to localhost/vocabulary, router redirects me to the right page. ...
exoslav's user avatar
  • 2,185
116 votes
13 answers
152k views

Use anchors with react-router

How can I use react-router, and have a link navigate to a particular place on a particular page? (e.g. /home-page#section-three) Details: I am using react-router in my React app. I have a site-...
Don P's user avatar
  • 62.5k
113 votes
17 answers
181k views

How to get current route path in Flutter?

While implementing persistent bottom bar, previous route need to be restored when a button in the bottom bar was clicked. When a button in the bottom bar is clicked, its current route path (/a/b/c) ...
Kyaw Tun's user avatar
  • 12.9k
112 votes
19 answers
402k views

laravel throwing MethodNotAllowedHttpException

I am trying to get something very basic running. I am used to CI and now learning Laravel 4, and their docs are not making it easy! Anyways, I am trying to create a login form and just make sure that ...
spacemonkey's user avatar
  • 2,550
108 votes
11 answers
212k views

laravel Unable to prepare route ... for serialization. Uses Closure

When I clear caches in my Laravel 5.2 project, I see this error message: [LogicException] Unable to prepare route [panel] for serialization. Uses Closure. I think that it's related with a route ...
Francesco's user avatar
  • 2,032
106 votes
5 answers
168k views

The requested resource does not support HTTP method 'GET'

My route is correctly configured, and my methods have the decorated tag. I still get "The requested resource does not support HTTP method 'GET'" message? [System.Web.Mvc.AcceptVerbs("GET", "POST")] [...
Rushino's user avatar
  • 9,465
102 votes
3 answers
103k views

Multiple optional route parameters in Express?

I am using Express to handle a route which is in the format of /articles/:year/:month/:day, where year, month and day are optional. If none of the three params is given, all articles will be returned;...
CLDev's user avatar
  • 1,537
100 votes
5 answers
101k views

Angular 2 - Submodule routing and nested <router-outlet>

I'm looking for a solution with Angular 2 for the scenario explained below: In this scenario, the top-nav contains links to load submodules and sub-nav has links to update the submodule's contents. ...
Ron F's user avatar
  • 1,041
98 votes
6 answers
249k views

How to use router.navigateByUrl and router.navigate in Angular

https://angular.io/api/router/RouterLink gives a good overview of how to create links that will take the user to a different route in Angular4, however I can't find how to do the same thing ...
Michael's user avatar
  • 1,117
96 votes
5 answers
79k views

How do I accept an array as an ASP.NET MVC controller action parameter?

I have an ASP.net MVC controller called Designs that has an action with the following signature: public ActionResult Multiple(int[] ids) However, when I try to navigate to this action using the url: ...
Grokys's user avatar
  • 16.5k
96 votes
5 answers
130k views

Web API Routing - api/{controller}/{action}/{id} "dysfunctions" api/{controller}/{id}

I have the default Route in Global.asax: RouteTable.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = System.Web.Http....
Mickael Caruso's user avatar
94 votes
6 answers
168k views

In express how do I redirect a user to an external url?

I have a payment system using node.js and braintree, when the payment is successful I want to send the user to the back end. My back end is setup elsewhere. I have tried res.writeHead(301, {...
Michael Joseph Aubry's user avatar
94 votes
5 answers
154k views

AngularJS - How can I do a redirect with a full page load?

I want to do a redirect that does a full page reload so that the cookies from my web server are refreshed when the page loads. window.location = "/#/Next" and window.location.href = "/#/Next" don't ...
Mike Pateras's user avatar
  • 14.9k
94 votes
4 answers
23k views

Routes with Dash `-` Instead of Underscore `_` in Ruby on Rails

I want my urls to use dash - instead of underscore _ as word separators. For example controller/my-action instead of controller/my_action. I'm surprised about two things: Google et al. continue to ...
pduey's user avatar
  • 3,736
93 votes
3 answers
43k views

Rails routing to handle multiple domains on single application

I've been unable to find a workable solution to this problem, despite several similar questions here and elsewhere. It seems likely that this question hasn't been answered for Rails 3, so here goes: ...
Aaron Vegh's user avatar
  • 5,217
90 votes
20 answers
189k views

My Routes are Returning a 404, How can I Fix Them?

I've just started learning the Laravel framework and I'm having an issue with routing. The only route that's working is the default home route that's attached to Laravel out of the box. I'm using WAMP ...
JasonMortonNZ's user avatar

1
2 3 4 5
670