首页 > Web开发 > 详细

Miniprofiler在普通net项目中的使用

时间:2016-03-14 10:41:53      阅读:761      评论:0      收藏:0      [点我收藏+]

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();

}

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

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

 

监控sql语句的运行时间

Var conn = new SqlConnection(“”);

If(MiniProfiler.Current == null) return conn;

Return new StackExchange.Profiling.Data.ProfiledDbConnection(conn, MiniProfiler.Current);

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

 

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>

 

Miniprofiler配置

MiniProfiler.Settings.PopupRenderPosition = RenderPosition.Right; // 提示条靠右显示

MiniProfiler.Settings.ShowControls = true; // 提示条上显示“m”和“c”

MiniProfiler.Settings.IgnoredPaths = new string[] { ".png", "/img/", "/js/" };// url请求中如果包含其中的内容,将不被监控

 

问题1

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

 技术分享

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

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

 

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

Alt + p

 

参考资料

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

Miniprofiler在普通net项目中的使用

原文:http://www.cnblogs.com/smallidea/p/5274803.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!