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.
ASP.NET Routing Debugger的更多相关文章
- ASP.NET路由[ASP.NET Routing]
ASP.NET路由[ASP.NET Routing] ASP.NET路由允许你在使用URL时不必匹配到网站中具体的文件,因为这个URL不必匹配到一个文件,你使用了描述用户行为且更容易被用户理解的URL ...
- .NET/ASP.NET Routing路由(深入解析路由系统架构原理)
阅读目录: 1.开篇介绍 2.ASP.NET Routing 路由对象模型的位置 3.ASP.NET Routing 路由对象模型的入口 4.ASP.NET Routing 路由对象模型的内部结构 4 ...
- 003. Asp.Net Routing与MVC 之一: 请求如何到达MVC
基础知识 本文用到的基础知识:URL.HttpModule 与 HttpHandler.IIS 的请求处理过程. URL HttpModule与HttpHandler IIS7.0的请求处理过程 OK ...
- .NET/ASP.NET Routing路由(深入解析路由系统架构原理)http://wangqingpei557.blog.51cto.com/1009349/1312422
阅读目录: 1.开篇介绍 2.ASP.NET Routing 路由对象模型的位置 3.ASP.NET Routing 路由对象模型的入口 4.ASP.NET Routing 路由对象模型的内部结构 4 ...
- NET/ASP.NET Routing路由(深入解析路由系统架构原理)(转载)
NET/ASP.NET Routing路由(深入解析路由系统架构原理) 阅读目录: 1.开篇介绍 2.ASP.NET Routing 路由对象模型的位置 3.ASP.NET Routing 路由对象模 ...
- ASP.NET Routing
ASP.NET Routing Other Versions ASP.NET routing enables you to use URLs that do not have to map to ...
- 一、ASP.NET Routing路由(深入解析路由系统架构原理)
阅读目录: 1.开篇介绍 2.ASP.NET Routing 路由对象模型的位置 3.ASP.NET Routing 路由对象模型的入口 4.ASP.NET Routing 路由对象模型的内部结构 4 ...
- 005. Asp.Net Routing与MVC 之三: 路由在MVC的使用
上次讲到请求如何激活Controller和Action,这次讲下MVC中路由的使用.本次两个关注点: 遗留:ModelBinder.BindModel的过程 MVC中路由的使用 MVC 5中的Acti ...
- 001. Asp.Net Routing与MVC 之(基础知识):URL
URL(Uniform Resoure Locator:统一资源定位器)是WWW页的绝对地址.URL地址格式排列为:scheme://host:port/path. 例如 http://www.zn. ...
随机推荐
- mysql8.0授权远程登录
之前一直用mysql5.6 远程授权登录,后来换mysql8.0原来的授权方式报错 mysql> grant all privileges on *.* to 'root'@'%' identi ...
- Android小经验:启动Eclipse,出现提示“......发现了以元素'd:skin'开头的无效内容。此处不应含有子元素...”
如图所示: 解决办法: 进入sdk目录下,把D:\android-sdks\system-images\android-22\android-wear\armeabi-v7a\devices.xml和 ...
- syzkaller安装
初始环境配置 sudo apt-get install subversion sudo apt-get install g++ sudo apt-get install git sudo apt in ...
- django工作原理简介
django工作原理简介 先简单的介绍一下django的工作原理,其中还会涉及到Middleware(中间件,包括request, view, exception, response),URLConf ...
- Redis未授权漏洞检测工具
Redis未授权检测小工具 #!/usr/bin/python3 # -*- coding: utf-8 -*- """ @Author: r0cky @Time: 20 ...
- Spring Security 流程
首先创建4个类 流程大致如下: 1.容器启动 加载系统资源与权限列表(HashMap) MyInvocationSecurityMetadataSourceService中的loadResourceD ...
- vue 数组更新检测注意事项
- DYNAMIC LINK LIBRARY - DLL
https://www.tenouk.com/ModuleBB.html MODULE BB DYNAMIC LINK LIBRARY - DLL Part 1: STORY What do we h ...
- 02-Elenment 引入使用
快速上手 本节将介绍如何在项目中使用 Element. ¶使用 vue-cli@3 我们为新版的 vue-cli 准备了相应的 Element 插件,你可以用它们快速地搭建一个基于 Element 的 ...
- 009——Matlab调用cftool工具的函数方法
(一)参考文献:http://blog.sina.com.cn/s/blog_4a0a8b5d0100uare.html (二)视频教程:https://v.qq.com/x/page/x30392r ...