ASP.NET Routing Debugger
How do you debug MVC 4 API routes?
解答1
RouteDebugger is good for figuring out which routes will/will not be hit.
http://nuget.org/packages/routedebugger
解答2
Another way is to add an event handler in Global.asax.cs
to pick up the incoming request and then look at the route values in the VS debugger. Override the Init
method as follows:
public override void Init()
{
base.Init();
this.AcquireRequestState += showRouteValues;
}
protected void showRouteValues(object sender, EventArgs e)
{
var context = HttpContext.Current;
if (context == null)
return;
var routeData = RouteTable.Routes.GetRouteData(new HttpContextWrapper(context));
}
Then set a breakpoint in showRouteValues
and look at the contents of routeData
.
Keep in mind that in a Web API project, the Http routes are in WebApiConfig.cs
, not RouteConfig.cs
.
ASP.NET Routing Debugger
PDATE: 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.
最新文章
- WebService中使用Aspose.Cells.dll
- windows下在文件夹中快速启动cmd
- 《你必须知道的.NET》读书笔记二:小OO有大原则
- 在使用androidStudio中所遇到的错误
- RabbitMQ官方中文入门教程(PHP版) 第一部分:Hello World
- Android studio 查看签名
- javascript中prototype、constructor以及__proto__之间的三角关系
- Transform-style和Perspective属性
- Java程序员从笨鸟到菜鸟之(二十一)java过滤器和监听器详解 【转】
- 从零开始学习jQuery (十一) 实战表单验证与自动完成提示插件
- DotNetCore跨平台~Dockerfile的解释
- 梳理:python—同一个类中的方法调用
- vue上传图片
- [转帖]Windows 10新预览版上线:可直接运行任意安卓APP了
- spring cloud ---->; RibbonClient设置的熔断器Hystrix不起作用
- 安装docker CE for CentOS
- Maven 问题笔记汇总
- 数据库mysql的常规操作
- 【IIS】IIS 7.0/7.5 无法启动 w3svc 服务
- Windows x64 栈帧结构
热门文章
- OpenStack kilo版(5) Neutron部署
- 还想免费继续使用JDK吗?从java11以后别从Oracle下载了
- Go数据类型之基本数据类型
- Linux提供哪些功能
- Java中实现图片的上传
- 重新编程Hexiwear Docking Station扩展坞
- Luogu P2935 最好的地方Best Spot
- Educational Codeforces Round 41 (Rated for Div. 2) D. Pair Of Lines (几何,随机)
- Python获取爬虫数据, r.text 与 r.content 的区别
- grep redis-cli command