Monday, December 17, 2012

How to Use Asp.Net MVC Routing Debugger Visualizer ?

What is MVC Routing Debugger Visualizer ?
  • It's an Extension for Visual Studio 2010
  • It Displays the Matched Route Data and Data Tokens of All Defined Routes in your web application
  • It's a Free Product

What is the Basic Requirement Needed for Run MVC Routing Debugger ?
  • Microsoft Visual Studio 2010 Any Edition Except Express Editions 

How to Install MVC Routing Debugger ?

Step 1. Open Visual Studio 2010

Step 2. Click  Tools  ---> Extension Manager

Extension Manager


Step 3. Click "Online Gallery" Button

Online Gallery


Step 4. Type "ASP.NET MVC Routing" inside the Search box

ASP.NET MVC Routing


Step 5. Click "Download" Button

Download


Step 6. Click "Install" Button

Install


Step 7. Click "Restart Now" Button for Restart Visual Studio 2010

Restart Now


That's It.You're Done.


How to Use MVC Routing Debugger ?

Step 1. Run Visual Studio 2010

Step 2. Open Your Asp.Net MVC Project

Step 3. Go to Your Action Method Which You Want to Find Route Details

Step 4. Set a Brake Point on it (Debug your Action Method)

Set a Brake Point

Step 5. Run Your Application

Step 6. When It Hits Your Brake Point , Open the "Watch Window"

Watch Window


Step 7. Add a New Watch Row for "System.Web.Routing.RouteTable.Routes"

New Watch Row


Step 8. Click on the "Magnifying Glass Icon" at the Right Side of the Value field on the
            New Watch Row

Magnifying Glass Icon


Step 9. The "MVC Routing Debugger Visualizer" should be Opened

MVC Routing Debugger Visualizer

  • You can see the Current URL in the Request Url Field
  • Grid of Currently-Defined Routes below that
  • Routes that Match the URL are Highlighted
  • Route Data and Data Tokens Grids are also Showing on the Right side

This is my Global.asax.cs

public static void RegisterRoutes(RouteCollection routes)
 {
  routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

  routes.MapRoute(
   "Default", // Route name
   "{controller}/{action}/{id}", // URL with parameters
   new { controller ="Home",action ="Index",id =UrlParameter.Optional }//defaults
                 );
  }

How to Change the Value in Request Url ?
  • Type the Request Url (e.g. ~/ShoppingCart)
  • Click "Match Routes" Buttons

Match Routes



That's It.You're Done.


Do You need to Know More Details ?
  • MVC Routing Debugger Visualizer Home

Conclusion
  • It's a very simple Tool for Use and Configure
  • It's running only on Debugger mode
  • When we're having route related issues, this is a tool for debug those issues
  • So Try This and Enjoy it

I hope this helps to You.Comments and feedback greatly appreciated.

Happy Coding


Tools for Visual Studio 2010

7 comments:

  1. You are an expert on this , You are fixing a issue most developers facing with IDE , s and working with GUI . Thanks alot

    ReplyDelete
    Replies
    1. Hi Hasitha,

      You're most welcome.
      Glad to hear that it helped.

      Delete
  2. Hello Sampath,

    I can pass through from step 1 to step 6. But Step 7 to step 9 I am not able execute it.
    When I am doing step 7 I am getting below mentioned values.

    Column:
    Name: System.Web.Routing.RouteTable.Routes
    Value: Count = 1
    Type: System.Web.Routing.RouteCollection

    So I failed from step 7 to step 9. Please help me to resolve this.

    Thanks in advance.

    ReplyDelete
    Replies
    1. Hello Sampath,

      Now I am able pass through from step 1 to step 9.
      Nice article.

      Thanks for your explorations and sharing :)

      Regards,
      Mukesh Selvaraj

      Delete
    2. i have the same Problem... it would be nice if you tell what was your solution!!

      Delete
    3. i've found a Description here: http://toreaurstad.blogspot.de/2011/12/blog-post.html

      NOW it Works...

      Delete
    4. Hi Mukesh & Howard,

      Thanks for the sharing different experience with us.
      I will check this thing and will update my post accordingly.

      Delete

Thanks for your Feedback.