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
35
votes
7 answers

on html.actionlink click go to previous page

Currently in a link Customer/businessunit/RepresentativeDetails?RepresentativeId=cd3a7263-78f7-41bd-9eb0-12b30bc1059a I have following code for view @Html.ActionLink("Back to List", "Index") which takes me to this…
Cybercop
  • 8,475
  • 21
  • 75
  • 135
35
votes
2 answers

How do I route images using ASP.Net MVC routing?

I upgraded my site to use ASP.Net MVC from traditional ASP.Net webforms. I'm using the MVC routing to redirect requests for old .aspx pages to their new Controller/Action equivalent: routes.MapRoute( "OldPage", …
The Matt
  • 6,618
  • 7
  • 44
  • 61
34
votes
3 answers

Rails 3 route appends _index to route name

I am migrating a Rails 2.3.8 version to Rails 3.0 and so ive rewritten my routes file. When i list the routes using rake routes, i see some route names have _index appended to them. I cant figure out why this is. Relevant routes: Rails…
zsquare
  • 9,916
  • 6
  • 53
  • 87
34
votes
5 answers

Routing nested resources in Rails 3

I have a pretty common case for nested routes, I feel like, that looks something like this (in some sort of pseudonotation): '/:username/photos' => Show photos for User.find_by_username '/photos' => Show photos for User.all In a nutshell: I have…
coreyward
  • 77,547
  • 20
  • 137
  • 166
34
votes
2 answers

How to rename REST routes in URL?

Give that I have a model called Apple and it has a controller ApplesController, the routes are: resources :apples apples GET /apples (.:format) {:controller=>"apples ", :action=>"index"} new_apple GET /apples /new(.:format) …
Zabba
  • 64,285
  • 47
  • 179
  • 207
34
votes
4 answers

Disable :.format routes in rails3

Could you tell me how to disable the .:format options in rails routes? I only need html...
BvuRVKyUVlViVIc7
  • 11,641
  • 9
  • 59
  • 111
34
votes
8 answers

Android - Getting audio to play through earpiece

I currently have code that reads a recording in from the devices mic using the AudioRecord class and then playing it back out using the AudioTrack class. My problem is that when I play it out it plays via the speaker phone. I want it to play out via…
Donal Rafferty
  • 19,707
  • 39
  • 114
  • 191
34
votes
2 answers

Angularjs routing in different files

I'm checking out angular routing. http://www.bennadel.com/blog/2420-Mapping-AngularJS-Routes-Onto-URL-Parameters-And-Client-Side-Events.htm The examples I see have all the routes be defined in the same file. How do I have various routes be defined…
Harry
  • 52,711
  • 71
  • 177
  • 261
34
votes
3 answers

Rails: How to modify tests for a nested resource?

While learning Rails I've created an application with a Domains controller nested below a Customers controller. I'm using Rails 2.3.4 and it's been a learning experience. I managed to get the below routing set up: customer_domains GET …
Martijn Heemels
  • 3,529
  • 5
  • 37
  • 38
33
votes
4 answers

How to add global route prefix in asp.net core 3?

Legacy .net core frameworks used UseMvc() for adding global route prefix. How to make it for asp.net core 3 without UseMvc() ?
Alex Zaitsev
  • 2,544
  • 5
  • 18
  • 27
33
votes
10 answers

How do I get Route name from RouteData?

I have several routes defined in my Global.asax; When I'm on a page I need to figure out what is the route name of the current route, because route name drives my site menu. How can this be done?
Andrey
  • 20,487
  • 26
  • 108
  • 176
33
votes
3 answers

Use redirectTo if you using also children parameter, is this possible?

As you probably already now in the latest @angular/router 3.0.0-rc.1 you are not allowed to user redirectTo parameter if you also use the children parameter. But for sure in some cases this is something that you need like in my case. For example…
Vassilis Pits
  • 3,788
  • 4
  • 33
  • 48
33
votes
7 answers

Rails Routes - Limiting the available formats for a resource

I have a series of resources that I want only available if accessed via the JS format. Rails' route resources gives me the formats plus the standard HTML. Is there a way to specify that only the JS format routes be created?
Eric M.
  • 5,399
  • 6
  • 41
  • 67
33
votes
28 answers

Error: .post() requires callback functions but got a [object Undefined] not working

there are several issues with the same theme, but I could not solve my problem. Error: Route.post() requires callback functions but got a [object Undefined] at Route.(anonymous function) [as post]…
Kevin AB
  • 543
  • 1
  • 4
  • 8
33
votes
1 answer

What is the difference between "express.Router" and routing using "app.get"?

I have an app with following code for routing: var router = express.Router(); router.post('/routepath', function(req, res) {}); Now I have to put routing code in different files so I tried to use this approach, but it is not working perhaps…
XIMRX
  • 2,130
  • 3
  • 29
  • 60