routing

Set new Default Folder / Controller

Is there a way to set a new Controller other than Home when a condition is met? I want to be able to specify a default controller other than Home when a user is logged in. So before a user logs in I want to use the default Home controller but once they have logged in I'd like to use say the User controller. Better yet is there a way t...

ASP.NET route passing string value

I'm trying to have a page on an ASP.NET MVC based web site where one page allows selecting by username instead of ID. I would have thought the route needs to be something like: routes.MapRoute( "CustomerView", "Customer/Details/{username}", new { username = "" } ); routes.MapRoute( "Default", "{controller}/{action}/{id}", new {...

asp.net MVC - Default route doesn't appear to be working

Hi there, I have setup some routes and they work so if i put localhost/MyWebApp/Reservas ...... it works. I have setup up a default route that if somebody enter localhost/MyWebApp it should go directly to the Reservas route ... but it doesn't.. I have installed a route debugger and it appears nothing matches the request.. am i doing ...

Simple MVC routing problem

I have few pages that quite similar to the others but one of them doesn't work. When I write 'http://localhost:2265/Segment/' I get annoying error message "Server Error in '/' Application. The resource cannot be found." Other pages like 'http://localhost:2265/User/' works very well AND also 'http://localhost:2265/Segment/Create'. So I...

String replacement in CakePHP routes

In my application, I have a number of controllers with the same prefix. For the sake of example, let's say they are: my_posts my_users my_letters The URLs generated for these are obviously: /my_posts/view/1 /my_users/add /my_letters/whatever I'd like to set up some custom routing so that I can use the URLs like this: /my/posts/vie...

Cakephp routing with optional params

I have a method in my users controller similar to: function members($type = null, $category = null) { ... } Both params are optional and can be used together or on their own. So with the following route. Router::connect('/members/*', array('controller' => 'users', 'action' => 'members')); http://example.com/users/members successfu...

How to route a multiple language URL with a MVC

I need multi language url route of existing controller. let's explain more: I have a controller with name "Product" and View with name "Software", therefore by default if user enter "http://mysite.com/en/Product/Software" ,get right content (that really exist in http://mysite.com/Product/Software), but i need if other user (french user...

Rails functional tests, routing error

I'm new to testing, and I'm having some difficulties trying to run a functional test. I've a messages_controller, and a user_controller here. in the routes, I've defined that the users resources has_many message resources. Now I'm trying to run a simple test in the messages controller: def test_index get :index, { :user_id => 1 } ...

Get all routes defined in global.asax

Hi there I am using webformrouting in my asp.net c# application. In my global.asax file i define a couple of routes. My question is, how can i get a list of all routes defined from code behind (on a page)? ...

How do I use a custom constraint with a HttpMethodConstraint in ASP.NET MVC routing?

I have a controller that only accepts a POST on this URL: POST http://server/stores/123/products The POST should be of content-type application/json, so this is what I have in my routing table: routes.MapRoute(null, "stores/{storeId}/products", new { controller = "Store", action = "Save" }, ...

Rails - Succinctly finding the parent resource of a polymorphically nested resource

Suppose I have a polymorphic structure like this. map.resources :bar, :has_many => :foo map.resources :baz, :has_many => :foo map.resources :qux, :has_many => :foo class Foo belongs_to :parent, :polymorphic => true end class FooController < AC before_filter :find_parent ... private def find_parent # ugly way: @parent = if ...

Mapping action input variables to an array via a route, with constraints

Hi there, I am trying to map a number of querystring variables into an array that is one of the parameters for an action method. The action method is as follows: public ActionResult Index(string url, string[] generics) { //controller logic here } We can easily get MVC to bind to the variable generics by using a querystring such as...

Restful routing with different controllers for the same resource resolving the "wrong" url

I have a Store model. And two controllers: stores_controller admin/stores_controller now in the list view of the admin/stores_controller I am trying to generate a link to the destroy action in the admin/stores_controller but every variation I have tried either goes to the stores_controller (so not the admin one) or to some other inco...

How to add page title in url in asp.net mvc? (url generation)

How to dynamically create urls/links like: www.restaurant.com/restaurant/restaurant-name-without-some-characters-like-space-coma-etc/132 what are the keywords i can use to google some articles on this topic? (how to genererate and handle this kind of urls inside asp.net mvc) There are some questions: How to generate links? (store slugs...

CodeIgniter routing problem. (appends ajax route to existing url)

I'm trying to perform an AJAX-request in a view, the user gives some input which is sent to the server with AJAX and the function it's supposed to go to is routed with CodeIgniters routes. This is the view I'm currently standing in while making the request. http://localhost:8888/companies/list In my route config I've set this route ...

ASP.NET MVC actions with optional params

I have an MVC action on my abstract BaseControlller like this (and this action is common across all inheriting controllers): // // GET: /controller/RenderForm/{formType} [Authorize(Roles = "Administrators")] public ActionResult RenderForm(FormType formType, BaseContentObject contentObject) { string constructP...

how to test asp.net mvc post actions using MvcContrib.TestHelper

I am trying to test my routing configuration using the excellent MvcContrib.TestHelper and I've run into a problem. Please assume that my Routing Configuration is set up correctly and initialised in the TestFixture. I have a controller (TransactionsController) action called Create that takes an input parameter of type TransactionReco...

Routing generated paths in Ruby on Rails

I'm a beginner in ruby-on-rails and I spent my last hour trying to do the following thing: I have a ruby-on-rails application - the blog with posts and categories. I want to have another URL for the posts (I would like to have http://localhost:3000/news instead of http://localhost:3000/posts) First I tried to replace the controller and...

Rails: How to parameterize access to a RESTful resource?

I'm looking for a restful way of passing through options to a service. Right now I have a devices resource accessed in standard rails manner with: map.resources :devices, :member => [:historical] So I can get my device with /devices/:id and I can get historical data with /devices/:id/historical I'd like to actually add a param onto ...

ASP.NET Routing - Adding a route only if numeric?

I am trying to generate a route using ASP.NET routing, but I only want it to apply if certain values are numeric. // Routing for Archive Pages routes.Add("Category1Archive", new Route("{CategoryOne}/{Year}/{Month}", new CategoryAndPostHandler())); routes.Add("Category2Archive", new Route("{CategoryOne}/{CategoryT...