Friday, November 7, 2014

Debugging Routes - ASP.NET MVC

After creating Custom Routes, you have to check whether your routes work perfectly with your given URL or not. For that, you have to debug your routes. To Debug Routes, you have to download one DLL from the http://code.haacked.com/mvc-1.0/RouteDebug-Binary.zip and add a reference into your MVC Application.
Now debug route you have to write the following line of the code into the Global.asax Application Start Event.

RouteDebug.RouteDebugger.RewriteRoutesForTesting(RouteTable.Routes);

And run your application. You will see the below screen in your browser:

RouteTesting.JPG
You can see all the custom routes into All Routes Table and it will show that your browser URL matches with which Routes. If it will match any Routes, it will show true into the Match Current Request Routes, otherwise it will show false. You can check with another URL, for that you have to write URL into the Address Bar.

No comments:

Post a Comment