MVC 2 AreaRegistration Routes Order

Aside from what Haacked said, it is very much possible to order area registrations (and thus their routes). All you have to do is register each area manually, in whatever order you want. It’s not as sleek as calling RegisterAllAreas() but it’s definitely doable. protected void Application_Start() { var area1reg = new Area1AreaRegistration(); var area1context … Read more

Asp.Net Routing: How do I ignore multiple wildcard routes?

There are two possible solutions here. Add a constraint to the ignore route to make sure that only requests that should be ignored would match that route. Kinda kludgy, but it should work. RouteTable.Routes.IgnoreRoute(“{folder}/{*pathInfo}”, new {folder=”content”}); What is in your content directory? By default, Routing does not route files that exist on disk (actually checks … Read more

Howto allow “Illegal characters in path”?

Scott Hanselman posted a good summary on allowing illegal characters in the path. If you really want to allow characters that are restricted, remove them from the list by editing your web.config (this will probably only work in .NET 4 and on IIS7): <system.web> <httpRuntime requestValidationMode=”2.0″ relaxedUrlToFileSystemMapping=”true” requestPathInvalidCharacters=”&lt;,&gt;,*,%,:,&amp;,\” /> </system.web> You may also need to … Read more

How can I redirect a user’s home (root) path based on their role using Devise?

Your routes.rb file won’t have any idea what role the user has, so you won’t be able to use it to assign specific root routes. What you can do is set up a controller (for example, passthrough_controller.rb) which in turn can read the role and redirect. Something like this: # passthrough_controller.rb class PassthroughController < ApplicationController … Read more

Testing route configuration in ASP.NET WebApi

I was recently testing my Web API routes, and here is how I did that. First, I created a helper to move all Web API routing logic there: public static class WebApi { public static RouteInfo RouteRequest(HttpConfiguration config, HttpRequestMessage request) { // create context var controllerContext = new HttpControllerContext(config, Substitute.For<IHttpRouteData>(), request); // get route data … Read more

How do I make a Catch-All Route in Laravel

You could also catch ‘all’ by using a regex on the parameter. Route::group([‘prefix’ => ‘premium-section’], function () { // other routes … Route::get(‘{any}’, function ($any) { … })->where(‘any’, ‘.*’); }); Also can catch the whole group if no routes are defined with an optional param. Route::get(‘{any?}’, function ($any = null) { … })->where(‘any’, ‘.*’); This … Read more