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
40
votes
9 answers

Can I group multiple domains in a routing group in Laravel?

Let's say I have the following: Route::group(array('domain' => array('admin.example.com')), function() { ... }); Route::group(array('domain' => array('app.example.com')), function() { ... }); Route::group(array('domain' =>…
Andy Fleming
  • 7,655
  • 6
  • 33
  • 53
40
votes
4 answers

Flask redirecting multiple routes

I'm trying to implement a redirecting pattern, similar to what StackOverflow does: @route('///') @route('//') def profile(id, username=None): user = User.query.get_or_404(id) if user.clean_username != username: …
Blender
  • 289,723
  • 53
  • 439
  • 496
40
votes
7 answers

Is there an standalone PHP routing library?

I'm looking to add some dynamic, REST-esque routing to a PHP application. I'd love to use an existing routing library so I don't have to reinvent the wheel. However, when I look at things like Slim and F3, they all come with things I don't…
abeger
  • 6,766
  • 7
  • 41
  • 58
40
votes
7 answers

Testing route configuration in ASP.NET WebApi

I am trying to do some unit testing of my WebApi route configuration. I want to test that the route "/api/super" maps to the Get() method of my SuperController. I've setup the below test and am having a few issues. public void GetTest() { var…
ahsteele
  • 26,243
  • 28
  • 134
  • 248
39
votes
8 answers

Getting Rails URL helpers to automatically output https urls

I am developing a site that mixes http and https a lot - whats the best/easiest way to make the links use the right protocol for the route - can it be specified in the routes file? Say I have the following route in Rails 3. match "/test" =>…
Joe Van Dyk
  • 6,828
  • 8
  • 57
  • 73
39
votes
2 answers

Routing optional parameters in ASP.NET MVC 5

I am creating an ASP.NET MVC 5 application and I have some issues with routing. We are using the attribute Route to map our routes in the web application. I have the following action: [Route("{type}/{library}/{version}/{file?}/{renew?}")] public…
Felipe Oriani
  • 37,948
  • 19
  • 131
  • 194
39
votes
2 answers

How is RedirectToRoute supposed to be used?

I have this in my Global.asax.cs: routes.MapRoute("BetaAccess", "beta-access", new { controller = "Beta", action = "Index" }); And this in my controller (index action on HomeController) and it definitely is getting…
Max Schmeling
  • 12,363
  • 14
  • 66
  • 109
38
votes
5 answers

Generating routes in javascript with Twig and Symfony2

Quite odd problem, sorry for asking, i'm quite new to Symfony/Twig. My route requires a mandatory region_id paramenter: ajax_provinces_by_region: pattern: /ajax/region/{region_id}/provinces defaults: {_controller:…
gremo
  • 47,186
  • 75
  • 257
  • 421
38
votes
4 answers

How do I route a URL with a querystring in ASP.NET MVC?

I'm trying to setup a custom route in MVC to take a URL from another system in the following format: ../ABC/ABC01?Key=123&Group=456 The 01 after the second ABC is a step number this will change and the Key and Group parameters will change. I need to…
Jason Underhill
  • 765
  • 1
  • 10
  • 18
38
votes
4 answers

How to remove controller names from rails routes?

I would like to trim down the routes on my application so that: http://myapplication.com/users/peter/questions/how-do-i-create-urls becomes... http://myapplication.com/peter/how-do-i-create-urls I have a users controller and would like it to be…
Peter Nixey
  • 16,187
  • 14
  • 79
  • 133
38
votes
9 answers

Individual declarations in merged declaration 'DepartmentListComponent' must be all exported or all local.ts(2395) Routing components

I have a problem with this code, I do it exactly like the video tutorial (I'm learning), but it doesn't work and calls for some declarations. It is possible that the code written in the guide is in some older methodology? Its hard code without…
MrToxity
  • 393
  • 1
  • 4
  • 8
38
votes
1 answer

Express routes parameters

I am trying to create two routes in my express app. One route, without a parameter will give me a list of choices, the other one with a parameter will give me the choice related to the id. router.get('/api/choice',…
Bram
  • 4,533
  • 6
  • 29
  • 41
38
votes
5 answers

AngularJs UI router - one state with multiple URLs

I have a request to add in another URL parameter that directs to a state that I already have set up. For efficiency purposes, I'm trying to see if I can add multiple URLs to point to the same state, or should I just use the $UrlRouterProvider.when()…
kretzm
  • 762
  • 1
  • 7
  • 14
37
votes
5 answers

Rails: how do you access RESTful helpers?

I'm trying to work through this guide to Rails routing, but I got stuck in section 3.3: Creating a RESTful route will also make available a pile of helpers within your application and then they list some helpers like photos_url, photos_path,…
Ethan
  • 57,819
  • 63
  • 187
  • 237
37
votes
2 answers

HAProxy - URL Based routing with load balancing

I am new to HAProxy and I have a question about HAProxy configuration which helps me make a key decision in taking the right approach. This will greatly help me deciding the architecture. I have 3 apps. Let's say app1, app2, app3. Each app is…
rohit369
  • 401
  • 1
  • 4
  • 4