所以我正在尝试将 MiniProfiler ( https://github.com/MiniProfiler/dotnet ) 用于 WebForms 网站。我所做的是:
添加 <%= StackExchange.Profiling.MiniProfiler.RenderIncludes() %> 语句
设置在 web.comfig
而且仍然 MiniProfiler 不起作用。简单的故障排除显示(在 Chrome 开发工具中)在该页面上我希望看到 MiniProfiler,我看到
http://localhost/mycoolsite/mini-profiler-resources/results 404.0 - 未找到
更多信息:我使用 .Net FW 4.5.1、IIS8 和 Intergated Mode(应用程序池)
任何想法可能对我有用?
在控制台应用程序中使用迷你分析器时,是否有可能获得与在 Web 应用程序中获得的相同级别的信息?理想情况下,我只想在控制台中自行托管 Web UI,但看起来这是不可能的。
我的主要目标是获取在调用时执行的 sqlqueries 及其参数/运行时间。我已经尝试过 RenderPlainText() 解决方案,它远没有 webview 那么详细,而且似乎没有一个钩子可以用来在发生有趣的事情时记录其内容。
我在我的项目中集成了 Entity Framework 和 CodeFirstStoredProc 库。我想记录两个库执行的查询。以前我使用 EF 提供的 Database.Log delegate,但由于我也想记录来自其他库的查询,因此我决定集成 Miniprofiler。
我使用下面的代码来获取变量中的查询日志result:
MiniProfilerEF6.Initialize();
MiniProfiler.StartNew("Test");
using (MiniProfiler.Current.Step("Level 1"))
{
DbConnection spConnection = new System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);
ProfiledDbConnection profileSpConnection = new ProfiledDbConnection(spConnection, MiniProfiler.Current);
using (EfDataContext db = new EfDataContext(profileSpConnection))
{
List<Domain.PersonEntity> data = db.Persons.ToList();
}
using (StoredProcedureContext db = new StoredProcedureContext(profileSpConnection))
{
List<GetPersonResult> data = db.GetPerson.CallStoredProc(new Domain.GetPersonParameter { IsActive = true }).ToList<GetPersonResult>();
}
string result = MiniProfiler.Current.RenderPlainText();
}
MiniProfiler.Current.Stop();
Run Code Online (Sandbox Code Playgroud)
我期望输出查询包含所有详细信息,但不幸的是我得到以下结果:
Manprit-PC at 11/15/2018 2:24:27 PM
Test = ms
> Level 1 = …Run Code Online (Sandbox Code Playgroud) 我在 asp.net core2.0 应用程序中使用 Miniprofiler。启动.cs
services.AddMiniProfiler(options => {
options.RouteBasePath = "/profiler";
(options.Storage as MemoryCacheStorage).CacheDuration = TimeSpan.FromMinutes(60);
options.SqlFormatter = new StackExchange.Profiling.SqlFormatters.InlineFormatter();
options.ResultsAuthorize = request => !Program.DisableProfilingResults;
});
Run Code Online (Sandbox Code Playgroud)
对于每个连接,我都会:
DbConnection connection = new System.Data.SqlClient.SqlConnection(_connectionString);
return new StackExchange.Profiling.Data.ProfiledDbConnection(connection, MiniProfiler.Current);
Run Code Online (Sandbox Code Playgroud)
示例取自此处https://miniprofiler.com/dotnet/HowTo/ProfileSql。在输出信息时,我看到静态内容(js、css等)的加载,包括数据库查询,我该如何禁用它?