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
26
votes
1 answer

Rails 3.0.3 resource route no index mapped?

I am trying to use a very simple resource route for my Buildings Controller. resource :buildings This results in the following mappings buildings POST /buildings(.:format) {:controller=>"buildings", :action=>"create"} new_buildings GET …
ibuck
  • 495
  • 1
  • 5
  • 16
26
votes
2 answers

What exactly is Dynamic Routing in ReactJS

I have been all around internet about the dynamic routing of React. But I couldn't find anything which explains how it works and how it is different than static routing in every single sense. I understood it pretty well how the things go when we…
Red fx
  • 1,071
  • 2
  • 12
  • 26
26
votes
4 answers

ASP.NET MVC QueryString defaults overriding supplied values?

Using ASP.NET MVC Preview 5 (though this has also been tried with the Beta), it appears that querystring defaults in a route override the value that is passed in on the query string. A repro is to write a controller like this: public class…
Greg Beech
  • 133,383
  • 43
  • 204
  • 250
26
votes
7 answers

Angular2 get url query parameters

I'm setting up a Facebook registration for my Angular2 web app. Once the application accepted via Facebook (after being redirected to the Facebook authorization page), it redirect to my webapp with the token and code as url…
Ben
  • 3,972
  • 8
  • 43
  • 82
26
votes
3 answers

MVC2 Routing with WCF ServiceRoute: Html.ActionLink rendering incorrect links!

I have a WCF service that lives side-by-side with an MVC2 web site. I'd like for my URL for the service to look like this: http://localhost/projdir/Service The MVC site is in its infancy so it still has all its boilerplate controllers etc. The…
roufamatic
  • 18,187
  • 7
  • 57
  • 86
26
votes
3 answers

Is it possible to call Express Router directly from code with a "fake" request?

Tangential to this question, I would like to find out if there is a way of triggering the Express Router without actually going through HTTP?
oligofren
  • 20,744
  • 16
  • 93
  • 180
26
votes
2 answers

Can someone explain asp.net routing syntax to me?

I am dealing with this code in a Web Forms scenario: public static void RegisterRoutes(RouteCollection routes) { Route r = new Route("{*url}", new MyRouteHandler()); routes.Add(r); routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); …
Petras
  • 4,686
  • 14
  • 57
  • 89
26
votes
5 answers

How would I have ui-router go to an external link, such as google.com?

For example: $stateProvider .state('external', { url: 'http://www.google.com', }) url assumes that this is an internal state. I want it to be like href or something to that effect. I have a navigation…
26
votes
9 answers

Codeigniter Routes regex - using dashes in controller/method names

I'm looking for a one line route to route dashed controller and method names to the actual underscored controller and method names. For example the URL /controller-name/method-name-which-is-long/ would route…
user137621
26
votes
6 answers

Basic Rails 404 Error Page

I have been looking for a simple answer to this for a ridiculously long time and it seems like this has to be so plainly obvious and simple because no one has an easy, idiot proof tutorial. Anyway, all I want to do is to have a single 404.html…
chrishomer
  • 4,900
  • 5
  • 38
  • 52
26
votes
1 answer

redirect by routing in angularjs

i have the following requirement: a list should be displayed for all items with edit and delete link. when user clicks on edit, edit form should appear with textboxes and a save button. now when user edits the data and clicks on the save button the…
z22
  • 10,013
  • 17
  • 70
  • 126
25
votes
2 answers

Raise an alert in rails controller without redirect

I just want to flash an notice/error if the message is/isn't saved, without any redirect, how can I have no redirect: respond_to do |format| if @message.save format.html { redirect_to request.referer, :notice => 'Message sent!' } #dont want…
hagope
  • 5,523
  • 7
  • 38
  • 52
25
votes
2 answers

rails 3.1 ActionController::RoutingError (No route matches [GET] "/assets/rails.png"):

Standard new rails app has issue showing the rails.png ActionController::RoutingError (No route matches [GET] "/assets/rails.png"): I have tried moving the .png file around to various places in assets and assets/images and also the older place…
Michael Durrant
  • 93,410
  • 97
  • 333
  • 497
25
votes
2 answers

Playframework route file: Separate Production routes from Dev routes

Is there a way in Play to annotate routes to inform that a certain section/group routes is only available in dev or prod mode
roshan
  • 1,323
  • 18
  • 31
25
votes
10 answers

Routing in Symfony2

How to setup default routing in Symfony2? In Symfony1 it looked something like this: homepage: url: / param: { module: default, action: index } default_symfony: url: /symfony/:action/... param: { module: default } default_index: url:…
umpirsky
  • 9,902
  • 13
  • 71
  • 96