MiniProfiler 和 WebForms

And*_*rko 3 webforms mvc-mini-profiler miniprofiler

所以我正在尝试将 MiniProfiler ( https://github.com/MiniProfiler/dotnet ) 用于 WebForms 网站。我所做的是:

  1. 使用 nuget 安装包
  2. 在 Global.asax.cs 中添加 MiniProfiler 初始化(Begin_request 和 End_request 事件)
  3. 添加 <%= StackExchange.Profiling.MiniProfiler.RenderIncludes() %> 语句

  4. 设置在 web.comfig

而且仍然 MiniProfiler 不起作用。简单的故障排除显示(在 Chrome 开发工具中)在该页面上我希望看​​到 MiniProfiler,我看到

http://localhost/mycoolsite/mini-profiler-resources/results 404.0 - 未找到

更多信息:我使用 .Net FW 4.5.1、IIS8 和 Intergated Mode(应用程序池)

任何想法可能对我有用?

Rob*_*Rob 7

我最近(非常!)写了一篇关于这个的博客,特别是让 MiniProfiler 在混合 WebForms/MVC 应用程序中工作的过程。

根据您概述的步骤,您似乎遗漏了(与我所拥有的相比):

<%= StackExchange.Profiling.ClientTimingHelper.InitScript %>
Run Code Online (Sandbox Code Playgroud)

也就是说,即使没有该行,我仍然会看到服务器端计时和 MiniProfiler UI,因此我怀疑您的web.config输入不正确。

检查以确保你已经把这个configuration> system.webServer>handlers中的web.config:

<add name="MiniProfiler" path="mini-profiler-resources/*" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" />
Run Code Online (Sandbox Code Playgroud)

您还可以检查其他一些事项:

  1. 您正在查看的页面是否位于子文件夹中,该子文件夹中是否包含web.config,或者位于它与添加handlers条目 which <clear />shandlers之间的文件夹中?
  2. 您的应用程序中是否还有其他内容可以捕获对 MiniProfiler 资源的请求并返回 404?