Miniprofiler在普通net项目中的使用

1、Global.asax中配置

Void Application_BeginRequest(Object sender, EventArgs e){
  If(Request.IsLocal){ //请求来自本地计算机
   StatckExchange.Profiling.MiniProfiler.Start(); 
  }
}

Void Application_EndRequest(Object sender, EventArgs e){
  StackExchange.Profiling.MiniProfiler.Stop();
}

2、 在页面的最底部可以输出用于在页面呈现结果的html标签

StackExchange.Profiling.MiniProfiler.RenderIncludes().ToHtmlString();

3、监控sql语句的运行时间

Var conn = new SqlConnection(“”);
If(MiniProfiler.Current == null) return conn;
Return new StackExchange.Profiling.Data.ProfiledDbConnection(conn, MiniProfiler.Current);

问题:返回的是dbconnection类型,无法强制转换为sqlconnection

4、Web.config文件中插入配置

<system.webServer> 
... 
<handlers> 
<add name="MiniProfiler" path="mini-profiler-resources/*" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" />
 </handlers> 
 <moudles runAllManagedModulesForAllRequests=”true” />
</system.webServer>

  5、Miniprofiler配置

MiniProfiler.Settings.PopupRenderPosition = RenderPosition.Right; // 提示条靠右显示
MiniProfiler.Settings.ShowControls = true; // 提示条上显示“m”和“c”
MiniProfiler.Settings.IgnoredPaths = new string[] { ".png", "/img/", "/js/" };// url请求中如果包含其中的内容,将不被监控

 

 

问题1Iis6中,加入miniprofilerjs文件显示404错误

 

问题2:左下角的mc不显示

iis7,应用连接池 > 高级设置 > 启用32位应用程序 > false

问题3:如何快速隐藏miniprofiler的左上角提示

Alt + p

 

 

参考资料

官网的使用说明: http://miniprofiler.com/

转载于:https://www.cnblogs.com/smallidea/p/5274803.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值