Asp.net MVC URL Routing Debugger

[Original Address]: the Url Routing Debugger

[Sic] Published: Mar 13, 2008

Mix in the meeting, Scott Hanselman's demonstration of a simple test program route (route tester), I quickly put them sorted out.

Route%20Tester%20-%20Windows%20Internet%20Explorer%20(2)_3.png

This tool displays the current contents of the address bar request Route data address in the presence of (the page where the Route Data). So you can enter various Urls in the address bar to observe it matches what a path. At the bottom of the page, showing the route list of all your programs are defined. It lets you see what route you define the current URL match.

The usefulness of this tool is that sometimes you want to match the path was another path definition is replaced. It can demonstrate to you this happens. However, this tool does not provide any information about why this happens. I hope we can do more things to improve this.

To use this tool, just download the zip file , then the dll file into the Bin directory in your program, and then add a line of code (in bold) in Appliation_Start function Global.asax.cs file in.

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

It will be used to update all those DebugRouteHandler route handler (IRouteHandler) your application, these original route handler to handler for each different route specifically defined. It adds a final catch-all route, in order to ensure that the debugger can always match all requests to this application.

I will publish all of the code (the use of " all " sounds like a lot of code, the code is actually not too much) it contains a demo of using this route tester program. This thing whether it is useful to you, please let me know.


 

Reproduced in: https: //www.cnblogs.com/dotLive/archive/2008/03/15/1106683.html

Guess you like

Origin blog.csdn.net/weixin_33788244/article/details/93765140