ASP.NET Routing Debugger

asp.net, asp.net mvc, code 0 comments suggest edit

UPDATE: I’ve added a NuGet package named “routedebugger” to the NuGet feed, which will make it much easier to install.

UPDATE 2: In newer versions of the NuGet package you don’t need to add code to global.asax as described below. An appSetting <add key="RouteDebugger:Enabled" value="true" /> in web.config suffices.

In Scott Hanselman’s wonderful talk at Mix, he demonstrated a simple little route tester I quickly put together.

Route Debugger
Screenshot

This utility displays the route data pulled from the request of the current request in the address bar. So you can type in various URLs in the address bar to see which route matches. At the bottom, it shows a list of all defined routes in your application. This allows you to see which of your routes would match the current URL.

The reason this is useful is sometimes you expect one route to match, but another higher up the stack matches instead. This will show you that is happening. However, it doesn’t provide any information why that is happening. Hopefully we can do more to help that situation in the future.

To use this, simply download the following zip file and place the assembly inside of it into your bin folder. Then in your Global.asax.cs file add one line to the Application_Start method (in bold).

protected void Application_Start(object sender, EventArgs e)
{
  RegisterRoutes(RouteTable.Routes);
  RouteDebug.RouteDebugger.RewriteRoutesForTesting(RouteTable.Routes);
}

This will update the route handler (IRouteHandler) of all your routes to use a DebugRouteHandler instead of whichever route handler you had previously specified for the route. It also adds a catch-all route to the end to make sure that the debugger always matches any request for the application.

I’m also making available the full source (using the word full makes it sound like there’s a lot, but there’s not all that much) and a demo app that makes use of this route tester. Let me know if this ends up being useful or not for you.

Technorati Tags: aspnetmvc,ASP.NET,routing

Found a typo or error? Suggest an edit! If accepted, your contribution is listed automatically here.

Comments

avatar

101 responses

  1. Avatar for Cleve Littlefield
    Cleve Littlefield March 13th, 2008

    It would be nice if similar to the way you can view Page.Trace events in if you had this was built-in viewer but configurable to shut off if this is the production site.

  2. Avatar for [mRg]
    [mRg] March 13th, 2008

    Awesome thanks Phil .. this will be very useful :)

  3. Avatar for Perry
    Perry March 13th, 2008

    Thanks Phil!
    When I saw this at Mix I was hoping you guys would release it even though it's not hard to do myself. I just felt this is one of those things to DRY ;)

  4. Avatar for Srikanth
    Srikanth March 14th, 2008

    Thanks Phil. Happen to see two web.config in the demo app and got an error "It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.".
    http://forums.devarticles.c...
    It seems the issue is, not to have two web.config inside the same solution, once i got rid of the web.config for the web app all golden!

  5. Avatar for Ben Scheirman
    Ben Scheirman March 14th, 2008

    Phil, any particular reason why this code accepts a route collection as a method parameter, but then goes ahead and accesses the RouteTable.Routes singleton directly?
    Is this an oversight, or is there a reason you did this?
    (I told Scott that we should call this BettererRouteHandler. Think about it...)

  6. Avatar for Haacked
    Haacked March 18th, 2008

    @Ben Yep, that's an oversight. Doh!

  7. Avatar for Haacked
    Haacked March 18th, 2008

    @Ben Fixed!

  8. Avatar for Damian Powell
    Damian Powell March 25th, 2008

    Nice one, Phil. As Cleve pointed out, it would be nice if this information was printed out *after* the normal processing of a page. If I get around to doing that, I'll send a copy back to you.

  9. Avatar for Brandon
    Brandon May 27th, 2008

    Just wanted to say thanks. I was stuck; this unstuck me. You're the man, Phil. Thank you.

  10. Avatar for Christian Schiffer
    Christian Schiffer June 2nd, 2008

    Hi thanks for this great tool. I tested it with preview 3 though and its not working, for some reason preveiw 3 of System.Web.Routing stated its version number to be 0.0.0.0 and obviously that there is a version conflict between my project and your dll.
    Will you do an update anytime soon?

  11. Avatar for Some One
    Some One June 3rd, 2008

    We kinda get the source code. One area we don't is with the Routing HTTP Module. This along with reflector helps explain what is going on inside system.web.routing. Thanx.

  12. Avatar for Billy Ho
    Billy Ho June 16th, 2008

    To make the RouteDebugger works with ASP.Net MVC Preview 3.
    All you have to do are the following items:
    1. Obtain the source code from the path below:
    http://haacked.com/code/RouteTesterDemo.zip
    2. Replace the follow assemblies in the \RouteTesterDemo\Dependencies directory with their ASP.Net MVC Preview 3 counterparts:
    System.Web.Abstractions.dll
    System.Web.Mvc.dll
    System.Web.Routing.dll
    3. Rebuild the RouteDebug project.
    The compiled assemblies which works with ASP.Net MVC Preview 3 can be obtained from the following path:
    \RouteTesterDemo\RouteTester\bin\Debug\RouteDebug.dll

    To make the sample project RouteTesterDemoWeb works with ASP.Net MVC Preview 3, a few addition steps are required:
    1. In HomeController.cs
    Modify:
    RenderView("Index");
    To:
    View("Index");
    2. In Web.Config
    Repalce all:
    "System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
    With:
    "System.Web.Routing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
    3. In Web.Config
    Replace all:
    "System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
    With:
    "System.Web.Abstractions, Version=0.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
    4. Rebuild the solution
    5. Launch your favourite web browser and test with the URL like below:
    http://localhost:14230/Home/Index
    (replace the port number 14230 to the one your Visual Studio.Net is using)

  13. Avatar for Richard Dingwall
    Richard Dingwall June 28th, 2008

    Thanks Billy - your instructions worked like a charm. I've uploaded updated ASP.NET MVC Preview 3 versions for anyone in a hurry: grab routedebug-preview3-binary.zip or routetesterdemo-preview3.zip. Cheers.

  14. Avatar for Simone Chiaretta
    Simone Chiaretta July 1st, 2008

    I remember someone posted a upgraded version of this tool that allowed switching on and off with a simple query string parameter, but cannot find it anymore.

  15. Avatar for Martin From
    Martin From July 25th, 2008

    Hey Phil and visitors,
    i have created this VS Solution that includes both the RouteDebugger, the RouteEvaluator, Demo Web and Tests.
    It is working with MVC Preview 4.
    Havent really changed any code except for marking a few classes internal.
    I have included a comment of what to do/remember, to make the Route Test work if implementing it in an existing solution.
    It can be downloaded here dc60.2shared.com/.../RouteHelper.zip

    Hope it can be of any use for someone out there.

    Martin From

  16. Avatar for Peter Kellner
    Peter Kellner September 9th, 2008

    not quite working with preview 5. when I download source, copy in 3 preview 5 dll's, build (no errors), run ..localhost/Home I get the errors:
    I'm hoping this helps strangeness. I create simple controller, simple view, and sometimes, the dots just do not connect and I get a blank page. Day 2 for me on MVC so it's probably me somehow.
    Object reference not set to an instance of an object.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
    Source Error:

    Line 125:
    Line 126: string display = string.Empty;
    Line 127: foreach (string key in values.Keys)
    Line 128: display += string.Format("{0} = {1}, ", key, values[key]);
    Line 129: if (display.EndsWith(", "))

    Source File: E:\temp\rtnew\RouteTesterDemo\RouteTester\DebugHttpHandler.cs Line: 127

  17. Avatar for perkins
    perkins September 11th, 2008

    I also meet the same problems! Haacked,Can you change the version to P5.Or could Anyone send a copy to me.Thanks

  18. Avatar for haacked
    haacked September 12th, 2008

    I updated the source to P5. :)

  19. Avatar for Darryl
    Darryl September 12th, 2008

    It still seems broken with Preview 5. It complains that DebugHttpHandler needs to be derived from MvcHandler.
    I don't know enough about MVC internals right now to fix it up. Making DebugHttpHandler derive from MvcHandler was not enough, now I don't get a crash but I also don't get any route tracing.
    Or maybe I am doing something else incorrectly.

  20. Avatar for Corin
    Corin September 15th, 2008

    Hi Phil,
    Do you want to remove the binary, or update that to preview 5. Judging from the comment above, it seems people are still trying to download this instead of the source.

  21. Avatar for haacked
    haacked September 15th, 2008

    I updated the binary. Sorry about that, I forgot that this post had two downloads.

  22. Avatar for darryl
    darryl September 15th, 2008

    Ok,
    I found my problem. When you create a new project in P5 it has the following code is the default.aspx code behind.
    HttpContext.Current.RewritePath(Request.ApplicationPath);
    IHttpHandler httpHandler = new MvcHttpHandler();
    httpHandler.ProcessRequest(HttpContext.Current);
    If you comment out this code the route debugger works.
    Otherwise it crashes on the third line with this exception
    System.ArgumentException was unhandled by user code
    Message="The MvcHttpHandler does not work with the handler of type 'RouteDebug.DebugHttpHandler' since it does not derive from MvcHandler.\r\nParameter name: httpHandler"
    Source="System.Web.Mvc"
    ParamName="httpHandler"
    StackTrace:
    at System.Web.Mvc.MvcHttpHandler.VerifyAndProcessRequest(IHttpHandler httpHandler, HttpContextBase httpContext)
    at System.Web.Routing.UrlRoutingHandler.ProcessRequest(HttpContextBase httpContext)
    at System.Web.Routing.UrlRoutingHandler.ProcessRequest(HttpContext httpContext)
    at System.Web.Routing.UrlRoutingHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext context)
    at mvctest._Default.Page_Load(Object sender, EventArgs e) in C:\Users\darryl\Documents\Visual Studio 2008\Projects\mvctest\mvctest\Default.aspx.cs:line 13
    at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
    at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
    at System.Web.UI.Control.OnLoad(EventArgs e)
    at System.Web.UI.Control.LoadRecursive()
    at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    InnerException:

  23. Avatar for celik
    celik September 16th, 2008

    This is such a cool stuff. Thank you man for providing us with such a tool

  24. Avatar for Anthony
    Anthony September 22nd, 2008

    It still seems broken with preview 5. I did the following:
    * make a new asp.net MVC solution, build it
    * Download the DLL
    * Add a reference to routeDebug.dll to the solution
    * Add the line to Application_Start
    * run the application
    - Get [ArgumentException: The MvcHttpHandler does not work with the handler of type 'RouteDebug.DebugHttpHandler' since it does not derive from MvcHandler.
    Parameter name: httpHandler]
    Commenting out the code in default.aspx (as suggested in the comments here) just produces a blank page.

  25. Avatar for Koistya `Navin
    Koistya `Navin September 25th, 2008

    Yeah, usefull stuff, I like it. Thanks for shareing, Phil.

  26. Avatar for balaji
    balaji October 6th, 2008

    Hi,
    I have downloaded the source and built the debugger using the MVC preview 5 and used it but still i am getting error.
    MvcHttpHandler does not work with the handler of type RouteDebug.DebugHttpHandler' since it does not derive from MvcHandler.
    Parameter name: httpHandler]
    please help

  27. Avatar for hudo
    hudo October 6th, 2008

    Just remove default.aspx, enter some valid url route or change code in defaut.aspx.cs to simple response.redirect. It crashes when redirecting request in default.aspx.cs, it seems they changed something in MvcHttpHanlder.ProcessRequest.

  28. Avatar for Jerry
    Jerry October 12th, 2008

    Hi hudo,
    I am having the same problem as balaji and I have tried removing the default.aspx to no avail. I am trying to integrate this with an existing application. When removing the routeDebug statement in the gobal.asax I get an error saying the request does not match any route. When I run the route debugger as a stan alone applation and put the route I'm trying to debug in it works.
    Please help.

  29. Avatar for Michael Stum
    Michael Stum November 9th, 2008

    Excellent stuff! any plans making it an integral part of ASP.net MVC? This really is a must-have Debugging Tool whenever someone wants to use Routing.

  30. Avatar for Ross
    Ross November 11th, 2008

    Nice work. Just what I was after!

  31. Avatar for Jonathan Parker
    Jonathan Parker March 13th, 2009

    Very useful. Thanks. Would be good if it had a way of enabling/disabling without having to recompile or restart the site.

  32. Avatar for Eric
    Eric March 16th, 2009

    I've just started an MVC project and definitely had some confusion about routes. This helped me understand which route was getting matched and why. Thanks so much!

  33. Avatar for Bart
    Bart January 7th, 2010

    Full source code zip is corrupt..
    Could you replace it with a working version? I would like to port this to work with MVC 2.0 (replace dependencies).
    Thanks!
    Bart

  34. Avatar for Tom
    Tom January 16th, 2010

    The source code archive appears to be broken. Can you please update?
    Understanding routing was the biggest headache I had learning ASP MVC. This debugger was incredibly helpful---I'd love to be able to step through it and build off it.
    Thank you for this!

  35. Avatar for Sean Iannuzzi
    Sean Iannuzzi January 20th, 2010

    The biggest issue I see with all of this is that you cannot step thru from Page Workflow from start to finish. In other words stepping into the entire page route. The tool is needed as a result of not having a fully integrated IDE when using MVC.

  36. Avatar for Andr&#233;s Panitsch
    Andr&#233;s Panitsch February 10th, 2010

    Thanks, Phil! After one frustrating hour of debugging this gave me the key (regular expressions are treacherous).

  37. Avatar for Terry Aney
    Terry Aney April 20th, 2010

    Made a slight change to check a config setting so that you don't have to rebuild to turn on and off the debugging...not sure if helpful, but here are my changes...(just my additions/changes listed)

    protected void Application_BeginRequest( object sender, EventArgs e )
    {
    if ( bool.Parse( ConfigurationManager.AppSettings[ "RouteDebug" ] ?? "false" ) )
    {
    RouteDebugger.RewriteRoutesForTesting( RouteTable.Routes );
    }
    else
    {
    RouteDebugger.RemoveTestingRoutes( RouteTable.Routes );
    }
    }

    Needed a way to restore RouteHandlers...

    public class DebugRoute : Route
    {
    ...
    public Dictionary<RouteBase, IRouteHandler> RouteHandlers { get; private set; }
    }

    Then changes to RouteDebugger...

    public static class RouteDebugger
    {
    public static void RemoveTestingRoutes( RouteCollection routes )
    {
    using ( routes.GetReadLock() )
    {
    var debugRoute = routes.FirstOrDefault( r => r == DebugRoute.Singleton );
    if ( debugRoute != null )
    {
    routes.Remove( debugRoute );
    foreach ( RouteBase routeBase in routes )
    {
    Route route = routeBase as Route;
    if ( route != null )
    {
    route.RouteHandler = DebugRoute.Singleton.RouteHandlers[ routeBase ];
    }
    }
    DebugRoute.Singleton.RouteHandlers.Clear();
    }
    }
    }
    public static void RewriteRoutesForTesting( RouteCollection routes )
    {
    using ( routes.GetReadLock() )
    {
    var debugRoute = routes.FirstOrDefault( r => r == DebugRoute.Singleton );
    if ( debugRoute == null )
    {
    routes.Add( DebugRoute.Singleton );
    foreach ( RouteBase routeBase in routes.Where( r => r != DebugRoute.Singleton ) )
    {
    Route route = routeBase as Route;
    if ( route != null )
    {
    DebugRoute.Singleton.RouteHandlers.Add( routeBase, route.RouteHandler );
    route.RouteHandler = new DebugRouteHandler();
    }
    }
    }
    }
    }
    }

  38. Avatar for eric
    eric April 26th, 2010

    Not that hard to make it work for MVC2, or framework 4.
    Just download the source code (above) and replace the System.Web, System.Web.Routing, and System.Web.Abstractions with the ones in the v4 Framework directory and rebuild. Worked for me.

  39. Avatar for W3bdev
    W3bdev May 3rd, 2010

    Not working for me in MVC2/4.

  40. Avatar for W3bdev
    W3bdev May 3rd, 2010

    I got it working. Download the DLL, create a new mvc project (don't try the download!), insert a reference to the dll. Add in the map route information you want to test, sample data is:
    routes.MapRoute("foo-route", "foo/{id}", new { controller = "Away", action = "Blah", id = (string)null });
    routes.MapRoute("bar-route", "bar/{id}", new { controller = "Home", action = "Index", id = (string)null });
    routes.MapRoute("token-route", "tokens/{id}", new { dataToken = "BlahBlahBlah" });
    routes.MapRoute("extension", "ext/{id}.mvc", new { controller = "Home", action = "Index", id = (string)null });
    routes.MapRoute("mvc-default", "{controller}/{action}/{id}"
    , new { controller = "Home", action = "Index", id = (string)null });
    And you should be good to go.

  41. Avatar for fschwiet
    fschwiet May 14th, 2010

    Just a note for those who thought they'd need to download the code and upgrade it for VS2010 / MVC2. RouteDebugger was added to MvcContrib.dll, which you may have already. For me, VS2010 added MvcContrib.dll to the project when I upgraded it from vs2008 to vs2010.

  42. Avatar for rn
    rn May 26th, 2010

    I am a bit frustrated, because when I user the Route debugger to check the routes, I get the green ticks at the right routes, but the moment I test it for real, I get a The resource cannot be found error. Using RTM .NEt 4 and MVC 2 with the spark view engine.

  43. Avatar for Rizaan Lakay
    Rizaan Lakay June 7th, 2010

    Hi, I love this debugger, except it confuses me more. :(
    Mathed Route: NO MATCH!
    Except in the table it matches a Route. And when I turn off the debugger, it throws a 404.
    Any ideas??

  44. Avatar for OsFoEl
    OsFoEl September 16th, 2010

    Awesome, thanks for your effort.

  45. Avatar for Simon
    Simon October 16th, 2010

    Hi i wonder if anyone could help an ASP MVC Noob.
    I'm coming from a CakePhP background so totally understand the MVC concept, just not the ASP syntax etc (which i'm learning).
    1)
    I've setup a basic C# MVC Application in VS2010 - MvcApplication1 for testing.
    I downloaded the RouteDebug.dll and dropped it into the bin directory (curiously the bin directory doesn't show in the Solution Explorer)
    Added: RouteDebug.RouteDebugger.RewriteRoutesForTesting(RouteTable.Routes); to the Application_Start method in Global.asax but RouteDebug is highlighted as not existing in current context. What have i missed?
    2)
    Another question regarding Routing, is it posible to apply regex to actions when adding a route, so the route only matches if the action is (edit|create|delete) for example.
    Many Thanks

  46. Avatar for CheerSun
    CheerSun October 28th, 2010

    ~#~
    ~#~
    ~@~

  47. Avatar for theCLu
    theCLu November 17th, 2010

    This is a fantastic tool! It just solved the issue I was having with a service route in my new MVC website. Thanks, Phil!

  48. Avatar for Oboro
    Oboro January 12th, 2011

    This is a life saver. This tool literal just saved my job. Thanks Phil. You are the man.

  49. Avatar for Dave
    Dave January 27th, 2011

    good. but maybe check the mvcroutevisualizer in codeplex

  50. Avatar for bigsan
    bigsan February 13th, 2011

    calling RouteTable.Routes.RegisterRoutes("~/...") in Application_Start is not enough, because it won't call the ReloadRoutes() at the first time while the file is not changed.
    ReloadRoutes() should be called after Listen() in RegisterRoutes(), doesn't it?

  51. Avatar for haacked
    haacked February 14th, 2011

    @bigsan I fixed it. Thanks!

  52. Avatar for Father
    Father March 4th, 2011

    i come from China.thank you for this software!

  53. Avatar for jeremy simmons
    jeremy simmons March 24th, 2011

    what about the same thing for outbound routes?

  54. Avatar for David Evans
    David Evans April 5th, 2011

    Thank you. This saved me some real time figuring out how my routes were screwed up. They worked fine in VS but then running under mono 2.6.4 on linux were less permissive, and your tool pointed out clearly what was different.

  55. Avatar for schizandrol a
    schizandrol a April 20th, 2011

    real time figuring out how my routes were screwed up. They worked fine in VS

  56. Avatar for grundt
    grundt June 1st, 2011

    newest version (2) is here:
    haacked.com/.../routedebugger-2.aspx

  57. Avatar for Saeed Neamati
    Saeed Neamati October 28th, 2011

    Haccked,
    I think I can use this code to implement a totally customized ASP.NET MVC authentication mechanism. In other words, I can use this to see which action has been requested, then see if that action has a special attribute (like NeedsLogin for example), etc.
    Do you think I really can use this code?

  58. Avatar for RYk
    RYk February 22nd, 2012

    Does this work with MVC4? I keep getting an error: Error1The type or namespace name 'RouteDebugger' does not exist in the namespace 'RouteDebug' (are you missing an assembly reference?)

  59. Avatar for Chris
    Chris April 23rd, 2012

    I just used it on MVC4 so yes. But I had to just add a reference to the RouteDebug.dll to keep VS happy so my F5 works. This is a great tool, helped me with a problem in no time. Great work!

  60. Avatar for Patrick
    Patrick June 8th, 2012

    Great tool. Thanks! I installed it onto VS11 RC using NuGet. I successfully debugged my MVC4 website.

  61. Avatar for Emil
    Emil June 15th, 2012

    It doesn't take into consideration when an action is marked [HttpPost] because in that case if you issue a GET URL the Route Debugger will say it has a match when it actually doesn't because the Action in the controller is POST and the typed action is GET.

  62. Avatar for Rob
    Rob June 19th, 2012

    Just tried this out in vs2012rc in asp.net mvc3 project.
    Installed from nuget in right project.
    But RouteDebug.RouteDebugger does not exist from the installed binary. I copied the content of RouteDebugger() from source into my own method and called that and it worked.
    I dont know why i cant see the RouteDebugger class.

  63. Avatar for Carl
    Carl July 4th, 2012

    I also installed this from nuget (RouteDebugger v2.1.3, VS2010 SP1, .Net 4, MVC 3) and had the same problem as Rob: RouteDebug.RouteDebugger does not exist.
    I also had to download the full source and find that code in RouteTesterDemo\RouteTester\RouteDebugger.cs.
    It seems the nuget package is incomplete, or else I've missed something somewhere.

  64. Avatar for Miha Markič
    Miha Markič July 14th, 2012

    Carl and Rob, the new version enables routing with a setting in web.config, no need for RouteDebugger code invocation.
    See haacked.com/.../routedebugger-2.aspx

  65. Avatar for Joel
    Joel July 18th, 2012

    Look's like someone else is trying to take credit for the debugger, or at the very least not give you credit.
    www.codeproject.com/...

  66. Avatar for haacked
    haacked July 18th, 2012

    @Joel he mentions the following URL code.haacked.com/mvc-1.0/RouteDebug-Binary.zip, but he really should point people to the NuGet package. :)

  67. Avatar for Joel
    Joel July 23rd, 2012

    @haacked, right you are Phil - I didn't notice that.

  68. Avatar for Shyju
    Shyju September 7th, 2012

    Phil,
    The latest version in NUGET does not have the RouteDebugger class. It will be good to provide some documentation about it.

  69. Avatar for constantin negut
    constantin negut November 25th, 2012

    H Scott,
    i ask myself if Routing Debugger works with windows 8,iis 7.5 10(contain http.sys versioned with iis7.5).

  70. Avatar for Desmond
    Desmond November 29th, 2012

    Hi, I did install your package from nuget. i can see the reference to the dll is also added correctlyt and in the web.config <add key="RouteDebugger:Enabled" value="true" /> is also added. Still im getting The Type or namespace name 'RouteDubug.RouteDebugger' does not exist in the namespace RouteDebug (Are you missing any reference?). I am using mvc4 in visual studio 2010. Thanks.

  71. Avatar for haacked
    haacked November 29th, 2012

    Please log an issue on the GitHub site with details. https://github.com/Haacked/RouteMagic/

  72. Avatar for NightKoder
    NightKoder November 30th, 2012

    Hi Phil,
    Same issue here, I downloaded RouteDebugger, and typed the following statement in Application_Start() in the Global.asax.cs file:
    RouteDebug.RouteDebugger.RewriteRoutesForTesting(RouteTable.Routes);
    Seeing the following error:
    "The type or namespace name 'RouteDebugger' does not exist in the namespace 'RouteDebug' (are you missing an assembly reference?)"
    The object browser doesn't show a "RouteDebugger" method for the RouteDebugger.

  73. Avatar for Michael W
    Michael W December 11th, 2012

    Hi - very nice add in. This works perfectly fine for me on VS2012 - just a quick question on exceptions/ysod , what config would you recommend in order to see the route debugger values when a ysod occurs?

  74. Avatar for Timanolan
    Timanolan January 8th, 2013

    What is the best way to test this with POSTs? It's working with Gets, but my issue is that I'm getting 404's on posts after upgrading a project a MVC 4 app from Beta. 

    I suppose I could use fiddler and look at the returned HTML, or create a JS method to Post the JSON by hand? 

  75. Avatar for SP
    SP March 22nd, 2013

    The RouteDebugger class is not included in the NuGet package for some reason. I just extracted the RewriteRulesForTesting() function and included it in the global.asax.cs. Sorry for the screencap. Forum kept munging the formatting.

  76. Avatar for SP
    SP March 22nd, 2013

    Image upload got munged, too. Just grab it from the source ZIP. Would be nice if the NuGet package was updated to include it.

  77. Avatar for Guest
    Guest March 30th, 2013

    +1

  78. Avatar for Luke Puplett
    Luke Puplett April 9th, 2013

    It now uses web.config instead of this class.

    <add key="RouteDebugger:Enabled" value="true"/>

  79. Avatar for demoncodemonkey
    demoncodemonkey May 18th, 2013

    Nice. I'm new to MVC so this helped me understand how routing works. Thanks!

  80. Avatar for John_Mc1
    John_Mc1 June 13th, 2013

    It would be nice if you could update this documentation to match that of the latest version on Nuget. It's effectively useless.

  81. Avatar for MSe
    MSe July 6th, 2013

    Thanks for the nice little utility.
    Just used it in troubleshoot a 404 issue and discovered that IIS is appending ".aspx" at the end of all api requests.

    I've asked the question on stackoverflow (http://stackoverflow.com/qu...

    Any input on the issue will be greatly appreciated.

    Thanks a bunch!

  82. Avatar for Dcompiled
    Dcompiled August 4th, 2013

    Please update the page to highlight the usage of web.config.

    RouteDebug.RouteDebugger.RewriteRoutesForTesting(RouteTable.Routes);

    Will not work with VS 2012 / MVC 4

  83. Avatar for Raman
    Raman February 18th, 2014

    Works great! Thanks! :)

  84. Avatar for Simon Shirley
    Simon Shirley May 21st, 2014

    Very useful! Got me out of a fix!

  85. Avatar for vurso
    vurso July 20th, 2014

    Very useful little package and even more capable when combined with Fiddler2

  86. Avatar for Awchie256
    Awchie256 July 29th, 2014

    I know that this is already too late but thanks dude. You saved me a day trying to work this routing problems out. I was stuck for 4 freaking hours trying to find out what the issue is. The only problem that happened (which was very stupid move of me) was the area registration. Since that the area registration is first, it conflicted all of the custom routes that I made specifically made for the certain area since that the default route is made by the area registration. I would have wasted a whole day if it weren't for your route debugger. Thank you very much.

  87. Avatar for Max
    Max October 1st, 2014

    Wow! After spending 3 hours not understanding why certain routes where giving me 404s, This tool made me find the problem in under 5 minutes...

    You sir, saved me a lot of time/money.

    Kudos!

  88. Avatar for firoz khan
    firoz khan October 12th, 2014

    SORRY MAY I GET SOURCE CODE OF ROUTING WORKING ON VISUAL STUDIO 2008......I AM NEW LEARNING PROGRAMMING C# I DO NOT HAVE 4.0 VERSION OF ASP.NET.

  89. Avatar for clevern
    clevern March 8th, 2015

    Hahaha... I went through the same issue about a year ago.
    I knew there was more to an email address than I was assuming, because back in the day I had an email address that looked more like a regular expression, something like:
    marcelo.calbucci%mandic@fapesp.com.br
    So, when I was writing my email validator in C# (regular expressions are too slow in some cases) I checked out the RFC, which is way more complex than anyone could ever imagine (except the people that wrote it).
    After a while I decided to limit the scope and not make it perfect, but good enough.
    The problem with making it match the spec is that somebody might mistype a symbol instead of a character and your regular expression will find it acceptable. I didn't want that to happen. If somebody has a weird symbol on their email address we'll simply reject it.

  90. Avatar for Me
    Me March 18th, 2015

    MS should add a built-in page to each ASP MVC app, when it is configured for debug, that provides utilities like this one or better ones to help developers.
    I would like a dynamic page at /routecheck/?url=<relative url="" here="">
    ..that would generate a table like the one shown in the article.

  91. Avatar for Ricardo Silva
    Ricardo Silva October 5th, 2015

    This tutorial is outdated. Project has changed. How can I register routes to debug with new source?
    Congrats for your initiative, but please, update post too!

  92. Avatar for ♪ RredCat
    ♪ RredCat February 3rd, 2016

    Check out Update 2 - it has answer.

  93. Avatar for Ronda
    Ronda June 16th, 2016

    I have used this app in the past but installing in Nopcommerce i am having an issue it says that RouteDebugger is not part of the namespace

    using RouteDebug;
    Global.asax

    This line throwing the error
    RouteDebug.RouteDebugger.RewriteRoutesForTesting(RouteTable.Routes);

  94. Avatar for ronda
    ronda June 16th, 2016

    Please delete this message too .... missed your comment about global and a new nuget and build worked. ~ Ronda

  95. Avatar for Vitor Canova
    Vitor Canova August 22nd, 2016

    Looks like the NuGet package is not available anymore.

  96. Avatar for haacked
    haacked August 22nd, 2016

    Weird, it shows up here: http://www.nuget.org/packag...
    Maybe there's a platform I need to support.

  97. Avatar for Jez
    Jez April 21st, 2017

    This doesn't work. I installed the RouteDebugger package via NuGet and "RouteDebug.RouteDebugger" doesn't exist! And adding the "RouteDebugger:Enabled" thing in web.config didn't work either.

  98. Avatar for Polyanskiy Daniil
    Polyanskiy Daniil June 15th, 2017

    Documentation update would be nice. Trying to get current version to work.

    UPD: Did it. It requires calling RouteDebug.PreApplicationStart.Start via PreApplicationStartMethod with setting "RouteDebugger:Enabled" = true in Web.config's appSettings.

  99. Avatar for Polyanskiy Daniil
    Polyanskiy Daniil June 15th, 2017

    A copy from my comment with the same problem.
    "UPD: Did it. It requires calling RouteDebug.PreApplicationStart.Start via PreApplicationStartMethod with setting "RouteDebugger:Enabled" = true in Web.config's appSettings."

  100. Avatar for Martin Kirk
    Martin Kirk May 14th, 2018

    OMG THIS IS AWESOME !

  101. Avatar for Andy
    Andy July 6th, 2018

    Just used this, worked fine for me with the web.config setting. Helped me to spot the problem very quickly.. probably saving me hours of head-scratching. THANKYOU FOR BUILDING THIS!