MiniProfiler 安装与设置
来源:互联网 发布:数据脱敏系统 编辑:程序博客网 时间:2024/05/20 00:51
Installation
Installation is simple and is all done through the Package Manager Console integrated into Visual Studio.
- Open the Package Manager Console (Tools -> Library Package Manager -> Package Manager Console.
- Type “Install-Package MiniProfiler” and press enter:
- Package Manager will now download and install MiniProfiler and add the required references to your project.
- As I mentioned previously, we’re going to be configuring MiniProfiler to profile our Entity Framework database context, in order to do so, we’ll also need the MiniProfiler.EF package, which is installed in exactly the same way, withCollapse | Copy Code
“Install-Package MiniProfiler.EF”
- Now open your Global.asax.vb file, at the top of your Sub Application_Start, add:Collapse | Copy Code
MiniProfilerEF.Initialize_EF42()
This ensures that any connections created and used by Entity Framework are captured and logged into MiniProfiler like in my screenshot above. - In the same file, add the following to the top of your Application_BeginRequest: Collapse | Copy Code
MiniProfiler.Start()
- And at the top of your Application_EndRequest: Collapse | Copy Code
MiniProfiler.Stop()
Almost done, I promise. We now need to add a piece of code to the page you want to see the profiler on. Personally I have this on my Base.Master, the parent master page for all others, that way it’s available on every page. The code you need to add, in your <head> tag is:
<%:MiniProfiler.RenderIncludes %> 这里如果不是MVC而是WebForm的话 请改成
<%= StackExchange.Profiling.MiniProfiler.RenderIncludes(useExistingjQuery:false) %>
webForm的话请放在页面的最下面(form下面)不然会报jquery引用错误,MVC暂时没试
You may need to add a reference to the namespace at the top of your page like so:
<%@ Import Namespace="StackExchange.Profiling" %>
And that’s it. It’s worth noting that if MiniProfiler.Start() isn’t called, the .RenderIncludes function is smart enough not to clutter your browser with the JavaScript files that are required. I personally wrap my .Start() in a Debugger.IsAttached statement, therefore I only show the profile in my local development environment.
Run your application and see what happens…
"Oh wait, Karl, you lied – it doesn’t work and I’m getting the following error when running MVC4"
Failed to load resource: the server responded with a status of 404 (Not Found) http://*/mini-profiler-resources/results
This article wouldn’t be interesting unless it solved at least one annoyance now, would it? To fix the above error you need to add the following to your Web.Config
<system.webServer> <handlers> <add name="MiniProfiler" path="mini-profiler-resources/*" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" />
This sorts out the routing issue which appeared in MVC4. Now try again, and you’ll be sorted!
Summary
MiniProfiler is a very powerful tool, I will go into the more advanced features of it in a later Article.
License
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)
- MiniProfiler 安装与设置
- MiniProfiler监控EF与.NET MVC项目
- 采用MiniProfiler监控EF与.NET MVC项目
- Jacorb 安装与设置
- jdk安装与设置
- xwiki安装与设置
- MongoDB 安装与设置
- Squid安装与设置
- spark 安装与设置
- IDEA 安装与设置
- MYSQL 安装与设置
- Terminator安装与设置
- Nop-Profiler的改进方向,通过Miniprofiler设置仅对某些条件下的访问开放profiler trace<七>
- Nop-Profiler的改进方向,通过Miniprofiler设置仅对某些条件下的访问开放profiler trace<七>
- MiniProfiler用法(转)
- MiniProfiler执行SQL语句
- Vsftpd安装与设置--匿名用户设置
- linux系统安全 -- 安装与设置
- duilib学习笔记
- android中使用dimen定义尺寸
- Ext.Ajax.request方法 参数
- jQuery冒泡
- 关于如何使用内容提供器Content Provider的简介
- MiniProfiler 安装与设置
- Sencha Touch 2.1 Chart属性中文解释
- Apache 三种MPM介绍
- MyEclipse svn 查看历史记录 乱码解决
- linux 路由表 的一些相关资料
- 4 Java学习之 反射Reflection
- 如果你喜欢上了一个程序员小伙_献给所有的程序员女友
- vs2010无法安装,framework就已经失败了
- [小说]魔王冢(18)平武那些事儿