RouteDebugger 2.0

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

I’m at Mix11 all week and this past Monday, I attended the Open Source Fest where multiple tables were set up for open source project owners to show off their projects.

One of  my favorite projects is also a NuGet package named Glimpse Web Debugger. It adds a FireBug like experience for grabbing server-side diagnostics from an ASP.NET MVC application while looking at it in your browser. It provides a browser plug-in like experience without the plug-in.

One of the features of their plug-in is a route debugger inspired by my route debugger. Over time, as Glimpse catches on, I’ll probably be able to simply retire mine.

But in the meanwhile, inspired by their route debugger, I’ve updated my route debugger so that it acts like tracing and puts the debug information at the bottom of the page (click to enlarge).

About Us - Windows Internet
Explorer

Note that this new feature requires that you’re running against .NET 4 and that you have the Microsoft.Web.Infrastructure assembly available (which you would in an ASP.NET MVC 3 application).

The RouteDebugger NuGet package includes the older version of RouteDebug.dll for those still running against .NET 3.5.

This takes advantage of a new feature included in the Microsoft.Web.Infrastructure assembly that allows you to register an HttpModule dynamically. That allows me to easily append this route debug information to the end of every request.

By the way, RouteDebugger is now part of the RouteMagic project if you want to see the source code.

To try it out, Install-Package RouteDebugger.

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

Comments

avatar

37 responses

  1. Avatar for Nazar Gargol
    Nazar Gargol April 12th, 2011

    This is definitely better solution than playing with Application_Start :)

  2. Avatar for Carlos
    Carlos April 12th, 2011

    I just updated to RouteDebugger 2.0 and now EVERY page of my site (webforms) shows the Route Debugger section at the end. How can I disable it?

  3. Avatar for Carlos
    Carlos April 12th, 2011

    Not only this but also adds the route debug section to the response of my json handlers making them return invalid JSON. =(

  4. Avatar for Ivan Franjic
    Ivan Franjic April 13th, 2011

    Great tool, thanks for updating it :)
    @Carlos you can 'disable' it by setting Copy Local property of RouteDebugger.dll to false.

  5. Avatar for Sasha
    Sasha April 14th, 2011

    do not understand how to use it :(

  6. Avatar for Fereshte
    Fereshte April 15th, 2011

    Ive just installed it , now I want to disable it. how i can do it?

  7. Avatar for haacked
    haacked April 15th, 2011

    I updated the RouteDebugger package. It now adds a Web.Config AppSetting. To disable it, set the setting to false.
    <appSetting key="RouteDebugger:Enabled" value="false" />

  8. Avatar for ik
    ik April 17th, 2011

    ik

  9. Avatar for Jack
    Jack April 18th, 2011

    I love this, now I can enable\disable route debugger on my local machine in one line!

  10. Avatar for Chris Sebok
    Chris Sebok April 19th, 2011

    Brilliant little tool, just used it to sort out a n00b issue I was having, will keep it around...
    However... it seemed to break my unobtrusive validation (using JQuery 1.5.1) - mainly my RemoteAttribute, though some of my RequiredAttribute model fields were breaking too... I disabled RouteDebugger and it all worked fine... just a heads up! Hit me up if you want some code examples :)

  11. Avatar for Eric Clark
    Eric Clark April 19th, 2011

    Great update, but I noticed that Nuget placed your license.txt at the top of my project, with no indication that it only covers RouteDebugger.dll. People could forget to remove the file and give users the impression their project is covered by your MS-PL license.

  12. Avatar for haacked
    haacked April 20th, 2011

    @Eric, Ah! I should rename the license.txt file to be specific to my package. Thanks.

  13. Avatar for alexandros
    alexandros April 27th, 2011

    With the old debugger I could see a trace in cases when my routes weren't working at all (an exception was thrown due to bad routes). is there a way to achieve this now?

  14. Avatar for Shane Whittet
    Shane Whittet April 27th, 2011

    Recommend investigating best place for License.txt file, as we don't necessarily want that file deployed.
    Regards!

  15. Avatar for Marc Simkin
    Marc Simkin May 4th, 2011

    With IIS 7.x, .Net 4, and MVC 3, if the application pool is set for classic mode, the HttpModule dynamic registration doesn't work.
    Any suggestions on how to get it to work in classic mode?
    thanks

  16. Avatar for Marc Simkin
    Marc Simkin May 4th, 2011

    Got it to work in classic mode. It seems that the issue is not routing but a 404/Page not Found. Shouldn't the routing info be displayed even with a page not found?

  17. Avatar for Jonas Stawski
    Jonas Stawski May 5th, 2011

    Awesome debugger, saved me a headache trying to figure out why the right action was not executing. Just FYI that jQuery breaks if using the route debugger. It is kind of annoying hitting the conitnue (or ignore) button in VS for every JS error. Other than that, great work, like usual...

  18. Avatar for Hardy Wang
    Hardy Wang May 31st, 2011

    Just not working. I installed from NuGet, added Microsoft.Web.Infrastructure.dll reference in my MVC3/.Net 4 project.
    After I launched my application, nothing about routing information showed up.

  19. Avatar for Troy
    Troy June 20th, 2011

    So how would I go about using RouteDebugger to debug Redirect Routes configured with RouteMagic?
    Currently the output shows n/a for all Redirect routes.

  20. Avatar for Neil Knight
    Neil Knight July 7th, 2011

    I have the same problem as Carlos. I have disabled the RouteDebugger in the web.config file, but all of my Javascript files break because it is inserting the CSS for the RouteDebugger. Any ideas on how to fix this? I've tried to remove the RouteDebugger and all references to it, but I still get the CSS in the Javascript files.

  21. Avatar for Tyson Benson
    Tyson Benson July 19th, 2011

    @Niel Knight: I found the same problem, my Javascript and CSS would have the route debugger html appended to the end of the response. I eventually found out it was the browser's cache persisting the route debugger as part of the response even after I disabled the route debugger, so I cleared my cache and everything was fine.

  22. Avatar for joj
    joj August 23rd, 2011

    I wanted the debugger mainly for debugging routes that don't work (meaning, error results: 404 or "I couldn't find the view, and I searched everywhere" type results). Routes that work are of little interest to me. The old debugger did this. The new one doesn't, or I have to configure stuff I don't know how to configure. I have gone back to the old debugger because of this.

  23. Avatar for Matt
    Matt November 2nd, 2011

    I don't think that catch all is working.. I'm a n00b to MVC but I need this to work for routes that do not match... having a lot of trouble with that for some reason..
    Any thoughts?

  24. Avatar for Chadrick
    Chadrick January 24th, 2012

    I've used this before the old Global.asax way. I've installed 2.1.2.0 using Nuget. No window is appended at the end of the page. I have the config app setting set to true. I noticed that I did not have Microsoft.Web.Infrastructure added to my MVC project refs and added that but it makes no diff. I'm debugging my app using ASP.NET Dev Server. Does this make a diff?

  25. Avatar for Jakka
    Jakka January 25th, 2012

    I also had the same problem as above. Installed Route Debugger 2.1.2 using NuGet, compile, and run the project using ASP.NET Dev Server... but no window is appended at the end of the page. And yes, I've the RouteDebugger:Enabled settings in the web.config set to true.
    I ended up using the github version and found out that all my requests to DebugHttpHandler is not processed because of the following line:

    if (!IsRoutedRequest(request) || !request.ContentType.Equals("text/html", StringComparison.OrdinalIgnoreCase))

    Somehow my current Request.ContentType always returns an empty string which is not equal to text/html :(

  26. Avatar for Chadrick
    Chadrick January 25th, 2012

    Also grabbed the RouteMagic solution from github, ran the RouteDebuggerDemoWeb project and nothing shows there either. Strange things...

  27. Avatar for Cluggas
    Cluggas January 26th, 2012

    I'm getting the same problem. NuGet package installed and enabled, but no route information appearing.
    @Jakka Request.ContentType is an empty string for GET requests, as far as understand it. Is this why your requests satisfy this condition?

  28. Avatar for Cluggas
    Cluggas January 26th, 2012

    That check for Request.ContextType is the cause of my problem. Setting it manually at the start of each request causes everything to work as expected.
    I totally see why the check is there - you would only want the route information attached to the page itself and not any other content - but should it not be a check on the response instead of the request? I can't be sure if that makes sense in the context of the code posted b @Jakka, but it would seem to make sense.

  29. Avatar for haacked
    haacked January 26th, 2012

    @Cluggas would you mind logging an issue in the GitHub repository?
    It's a better place to discuss it. I'll look into it and we can hash out what the proper solution should be there. Would love your help in thinking it through. :)

  30. Avatar for Erik
    Erik April 13th, 2012

    I've installed the RouteDebugger, but can't see any route debugging? The web.config option is enabled <add key="RouteDebugger:Enabled" value="true" /> why?
    No errors, just the site as before installing RouteDebugger?

  31. Avatar for Won
    Won May 14th, 2012

    Works just fine. Thank you
    RouteDebugger via Nuget Version 2.1.3.0
    IIS 7.5
    .NET 4
    MVC3
    Web.config transformation

  32. Avatar for Dmitry Pavlov
    Dmitry Pavlov June 14th, 2012

    Thanks! Such thing should be a part of ASP.NET MVC it self.

  33. Avatar for Dmitry Pavlov
    Dmitry Pavlov June 14th, 2012

    You could vote for idea to add such Route Debugger to IDE visualstudio.uservoice.com/...

  34. Avatar for Umed Singh Bisht
    Umed Singh Bisht June 15th, 2012

    Thanks for such a useful tool.
    Using it in ASP.NET 4.0 WebForms website.
    RouteDebuger generated info:
    Matched Route: trackjob
    Generated URL: /error/404?sqs=Qyoi7TQYB927JGxc%2Be9BINlUYaNk8XiAZ2BpIdMWGZBKniVrzQ3g8RiH36y5dblx using the route "error/404"

    Matches Current Request Url
    .... ....
    .... ....
    True trackjob
    .... ....
    .... ....

    Current Request Info
    AppRelativeCurrentExecutionFilePath is the portion of the request that Routing acts on.
    AppRelativeCurrentExecutionFilePath: ~/trackjob
    --------------
    blockquoteGenerated URLblockquote should be blockquote/trackjob/?sqs=.....blockquote
    OR
    Is it OK or some issue with my order or way of creating Route Maps?

  35. Avatar for Ebalders
    Ebalders July 7th, 2014

    Any chance you are familiar with any project similar to this that deals with how view locations are searched?

  36. Avatar for haacked
    haacked July 8th, 2014

    Maybe http://getglimpse.com/?

    I did something a long time ago but forgot to publish it.

  37. Avatar for larrybud
    larrybud February 12th, 2018

    This is an old utility, but a good one. One thing I ran across was the routeDebugger info just disappeared... well, turns out you need to have CustomErrors OFF when trying to find your bad route, otherwise my custom error page just displays.