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
51
votes
4 answers

Creating a rails route to an external URL

A lot of my users keep going to http://(rails app URL)/blog, but I don't actually have a blog. I finally setup a Posterous blog and now want to direct my users there. Is there a way to configure this using routes.rb? Is there a better way that…
Chris
  • 1,091
  • 1
  • 8
  • 18
50
votes
7 answers

IIS URL Rewriting vs URL Routing

I was planning to use url routing for a Web Forms application. But, after reading some posts, I am not sure if it is an easy approach. Is it better to use the URL Rewrite module for web forms? But, it is only for IIS7. Initially, there was some buzz…
Gulzar Nazim
  • 51,744
  • 26
  • 128
  • 170
50
votes
6 answers

Rails Routing (root :to => ...)

I know how to set the routes root of my rails app to a controller and an action. But how to add an id? /pages/show/1 should be the root. How do I set this?
Joern Akkermann
  • 3,542
  • 8
  • 33
  • 41
50
votes
4 answers

Flutter Redirect to a page on initState

I have an application where you need to log in to continue (for example with Google). I would like to redirect the user when the authentification is needed. However when I run a Navigator.of(context).pushNamed("myroute"). I got the following error: …
Alexi Coard
  • 7,106
  • 12
  • 38
  • 58
50
votes
5 answers

How to get :id param of child route from parent component in Angular2

I'm trying to get the :id param defined in RouterModule.forRoot([ { path: 'orders', component: ListComponent, children: [ { path: 'view/:id', component: ViewComponent }, ] } ]) from ListComponent. I…
50
votes
6 answers

Automatically generate lowercase dashed routes in ASP.NET Core

ASP.NET Core uses CamelCase-Routes like http://localhost:5000/DashboardSettings/Index by default. But I want to use lowercase routes, which are delimitted by dashes: http://localhost:5000/dashboard-settings/index They're more common and consistent,…
Lion
  • 16,606
  • 23
  • 86
  • 148
50
votes
8 answers

Rails: Preserving GET query string parameters in link_to

I have a typical search facility in my app which returns a list of results that can be paginated, sorted, viewed with a different records_per_page value, etc. Each of these options is controlled by parameters in the query string. A simplified…
Vincent
  • 16,086
  • 18
  • 67
  • 73
50
votes
7 answers

What's so RESTful about ASP.NET MVC?

REST has been such a popular buzzword for the last couple of years (or so) and when ASP.NET MVC rolled out, everyone was relating REST with ASP.NET MVC. I also fell for the buzz and from the lack of my knowledge, my understanding of REST was simply…
Robert Koritnik
  • 103,639
  • 52
  • 277
  • 404
48
votes
1 answer

Express Router undefined params with router.use when split across files

I'm not sure if this is a bug in Express, or if I'm just doing something wrong (probably the latter), but I'm finding that req.params is only retaining parameters in the final step of the request. To demonstrate what I mean: Working…
whitfin
  • 4,539
  • 6
  • 39
  • 67
48
votes
8 answers

Laravel form html with PUT method for PUT routes

I Have this in my routes : +--------+---------------------------+--------------+--------------------------- …
48
votes
11 answers

HttpContext.Current.Session is null when routing requests

Without routing, HttpContext.Current.Session is there so I know that the StateServer is working. When I route my requests, HttpContext.Current.Session is null in the routed page. I am using .NET 3.5 sp1 on IIS 7.0, without the MVC previews. It…
Loki
  • 1,159
  • 1
  • 9
  • 11
48
votes
1 answer

How to detect if rails is at the root url?

What I want is seems simple. In my application helper i setup this module ApplicationHelper def isroot if root_url @container = "mainbox" else @container = "maincontainerbox" end end end in my application layout i have this
Fresh
  • 757
  • 1
  • 7
  • 18
47
votes
14 answers

Image equivalent of ActionLink in ASP.NET MVC

In ASP.NET MVC is there an equivalent of the Html.ActionLink helper for Img tags? I have a controller action that outputs a dynamically generated JPEG and I wanted to use the same Lambda expressions to link to it as I do HREFs using…
Jason Whitehorn
  • 13,585
  • 9
  • 54
  • 68
47
votes
3 answers

How can I have optional parameters in Symfony2 route?

I have this code below: /** * Lists all User entities. * * @Route("/{cid}",defaults={"cid" = null},name="user") * @Template() */ public function indexAction($cid=null) {} Now if I type site/user/1 then it works, but if I type site/user/ it…
Mirage
  • 30,868
  • 62
  • 166
  • 261
46
votes
2 answers

Difference between resource and resources methods

What is the logical difference between resource and resources methods Here is some examples: resource :orders, :only => [:index, :create, :show] > rake routes orders POST /orders(.:format) orders#create GET …
alexkv
  • 5,144
  • 2
  • 21
  • 18