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

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 as a client-side routing to switch between pages…
heartmon
  • 1,411
  • 2
  • 13
  • 14
114
votes
11 answers

React-router v4 - cannot GET *url*

I started to use react-router v4. I have a simple in my app.js with some navigation links (see code below). If I navigate to localhost/vocabulary, router redirects me to the right page. However, when I press reload (F5) afterwards…
exoslav
  • 2,094
  • 3
  • 21
  • 26
114
votes
8 answers

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 to use this middleware only on specific…
Thomas
  • 10,289
  • 13
  • 39
  • 55
113
votes
2 answers

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){ function makeRandom(){ var text = ""; …
Qcom
  • 18,263
  • 29
  • 87
  • 113
112
votes
19 answers

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 data is posted successfully by printing it in the…
spacemonkey
  • 2,530
  • 6
  • 23
  • 27
111
votes
12 answers

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-wide navbar that needs to link to a particular parts of…
Don P
  • 60,113
  • 114
  • 300
  • 432
108
votes
11 answers

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 Route::get('/article/{slug}',…
Francesco
  • 2,042
  • 2
  • 19
  • 29
108
votes
19 answers

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' => 'order.details', 'https']); url($language.'/index', [],…
Nelson Melecio
  • 1,334
  • 3
  • 12
  • 19
106
votes
5 answers

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")] [System.Web.Mvc.HttpGet] public string Auth(string…
Rushino
  • 9,415
  • 16
  • 53
  • 93
98
votes
4 answers

Angular 2 - Submodule routing and nested

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. The URLs should map as: /home => loads the home…
Ron F
  • 1,021
  • 1
  • 8
  • 4
97
votes
12 answers

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) is saved and previously saved route is restored…
Kyaw Tun
  • 12,447
  • 10
  • 56
  • 83
96
votes
3 answers

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; If year is given, articles of that year will be…
CLDev
  • 1,467
  • 1
  • 15
  • 19
96
votes
5 answers

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.RouteParameter.Optional } ); I wanted to…
Mickael Caruso
  • 8,721
  • 11
  • 40
  • 72
95
votes
6 answers

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 programmatically rather needing the user to click a link
Michael
  • 1,087
  • 1
  • 9
  • 12
94
votes
5 answers

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…
Grokys
  • 16,228
  • 14
  • 69
  • 101