我想将MVC MiniProfiler的结果保存到sql server数据库.我分析了一个高负载的mvc4页面,以发现一个棘手的性能问题,这个问题在我们的测试或开发系统上是不可重现的,只是偶尔在生产服务器上发生.
连接迷你探查器的最佳方法是什么?是否有现成的扩展名?
如何在C#控制台应用程序中使用mvc-mini-profiler?
同样好奇的是,mvc mini profiler是否将实际的配置文件统计信息放在每个网页的左侧,还是仅手动完成自定义javascript代码?
我下载并运行了mvc示例,但找不到将结果放入javascript弹出窗口的代码.
我有一个单页javascript应用程序(使用JavascriptMvc完成)和一个后端,REST服务构建在ASP.NET MVC3之上(使用NServiceMVC完成).
REST服务安装并运行了MiniProfiler,并且每个AJAX请求都会返回X-MiniProfiler-Ids标头.我确实有miniprofiler运行和工作,但我找不到任何关于此的信息,所以我不确定我是否正确地做到了这一点.
这是一个受支持的方案,现在有一种特定的方法吗?
我目前正在做的是:
在HTML应用程序(这是所有静态代码,没有动态的东西),我有:
<script type="text/javascript" src="/api/profiler"></script>
Run Code Online (Sandbox Code Playgroud)
在我的MVC应用程序中,我有:
public ActionResult Profiler()
{
if (!ControllerContext.HttpContext.IsDebuggingEnabled)
{
return new EmptyResult();
}
return new ContentResult() {
Content = StackExchange.Profiling.MiniProfiler.RenderIncludes(
position: RenderPosition.Right,
showControls: true
)
.ToString()
.Replace("<script type=\"text/javascript\">", "")
.Replace("</script>", "")
};
}
Run Code Online (Sandbox Code Playgroud)
很明显,这里有一个黑客删除硬编码<script>标签.
除此之外,从MVC的其他方面来看,profiler与通常使用完全相同.当您在应用程序中执行导致REST调用的操作时,miniprofiler会在角落中显示它.使用该showControls:true参数在这里也非常有用所以清除按钮会显示,因为否则您只需获得一个常量的操作列表,因为整个页面基本上不会刷新.
这是"正确"的方式吗,还是有更好的方法?
在ASP.NET MVC迷你探查看起来真棒,但我不明白的LINQ的2 SQL使用示例.
这是profiler文档中的Linq2SQL示例:
partial class DBContext
{
public static DBContext Get()
{
var conn = ProfiledDbConnection.Get(GetConnection());
return new DBContext(conn);
// or: return DataContextUtils.CreateDataContext<DBContext>(conn);
}
}
Run Code Online (Sandbox Code Playgroud)
我如何在实际应用中使用它?我本来期望我的DataContext有一些包装器,但这似乎以不同的方式工作.我甚至不知道定义了示例中的"GetConnection()"方法的位置.
谢谢,
阿德里安
有没有人能够让IIS 6上的MVC迷你探测器工作?我在我的应用程序中设置了探查器,它在Visual Studio,IIS Express和IIS 7.5中运行良好,但是当我将完全相同的应用程序放到IIS 6上时它将无法工作.
问题似乎是加载/mini-profiler-includes.js,我只得到404响应.我检查了路由表,并且探查器已经注册了正确的路由,但除此之外,我不知道还有什么可以尝试.
刚刚将一个 Web 项目升级到 .NET 6.0。项目已编译,但当我运行该网站时,出现以下错误:
InvalidOperationException:找不到包“System.Security.Cryptography”的编译库位置。
我正在使用 MiniProfiler.AspNetCore.Mvc 4.2.2。为了调试,我添加了 NuGet System.Security.Cryptography.Pkcs 包,但这并不能解决问题。
有什么解决问题的想法吗?
堆栈显示MiniProfilerMiddleware.cs正在引发异常:
InvalidOperationException: Cannot find compilation library location for package 'System.Security.Cryptography.Pkcs'
Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths(ICompilationAssemblyResolver resolver, List<string> assemblies)
Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths()
Microsoft.AspNetCore.Mvc.ApplicationParts.AssemblyPartExtensions+<>c.<GetReferencePaths>b__0_0(CompilationLibrary library)
System.Linq.Enumerable+SelectManySingleSelectorIterator<TSource, TResult>.MoveNext()
System.Collections.Generic.List<T>.InsertRange(int index, IEnumerable<T> collection)
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation.RazorReferenceManager.GetReferencePaths()
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation.RazorReferenceManager.GetCompilationReferences()
System.Threading.LazyInitializer.EnsureInitializedCore<T>(ref T target, ref bool initialized, ref object syncLock, Func<T> valueFactory)
System.Threading.LazyInitializer.EnsureInitialized<T>(ref T target, ref bool initialized, ref object syncLock, Func<T> valueFactory)
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation.RazorReferenceManager.get_CompilationReferences()
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation.LazyMetadataReferenceFeature.get_References()
Microsoft.CodeAnalysis.Razor.CompilationTagHelperFeature.GetDescriptors()
Microsoft.AspNetCore.Razor.Language.DefaultRazorTagHelperBinderPhase.ExecuteCore(RazorCodeDocument codeDocument)
Microsoft.AspNetCore.Razor.Language.RazorEnginePhaseBase.Execute(RazorCodeDocument codeDocument)
Microsoft.AspNetCore.Razor.Language.DefaultRazorEngine.Process(RazorCodeDocument document)
Microsoft.AspNetCore.Razor.Language.DefaultRazorProjectEngine.ProcessCore(RazorCodeDocument codeDocument)
Microsoft.AspNetCore.Razor.Language.RazorProjectEngine.Process(RazorProjectItem projectItem)
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation.RuntimeViewCompiler.CompileAndEmit(string relativePath)
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation.RuntimeViewCompiler.OnCacheMiss(string normalizedPath)
Microsoft.AspNetCore.Mvc.Razor.Compilation.DefaultRazorPageFactoryProvider.CreateFactory(string …Run Code Online (Sandbox Code Playgroud) asp.net asp.net-mvc mvc-mini-profiler miniprofiler asp.net-core
我引用了MvcMiniProfiler的1.6版本(通过Nuget),并按照项目主页http://code.google.com/p/mvc-mini-profiler/上的说明设置了所有内容.
我在Web.config中有以下代码:
<system.data>
<DbProviderFactories>
<remove invariant="MvcMiniProfiler.Data.ProfiledDbProvider" />
<add name="MvcMiniProfiler.Data.ProfiledDbProvider" invariant="MvcMiniProfiler.Data.ProfiledDbProvider" description="MvcMiniProfiler.Data.ProfiledDbProvider" type="MvcMiniProfiler.Data.ProfiledDbProviderFactory, MvcMiniProfiler, Version=1.6.0.0, Culture=neutral, PublicKeyToken=b44f9351044011a3" />
</DbProviderFactories>
</system.data>
Run Code Online (Sandbox Code Playgroud)
(项目主页的版本= 1.5.0.0 - NuGet包已经更新)
我在Global.asax中有以下代码(以及在Web.config中定义的连接字符串):
protected void Application_Start()
{
Log.Info("ReCoupon has started.");
AreaRegistration.RegisterAllAreas();
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
var factory = new SqlConnectionFactory(ConfigurationManager.ConnectionStrings["ReCouponContext"].ConnectionString);
var profiled = new MvcMiniProfiler.Data.ProfiledDbConnectionFactory(factory);
Database.DefaultConnectionFactory = profiled;
Database.SetInitializer(new ReCouponContextInitializer());
}
Run Code Online (Sandbox Code Playgroud)
分析器工作得很好,除了我不能让它来分析SQL.我正在使用SQL Server 2008 Express.我一直在关注Google Code项目主页上的相关问题而且完全陷入困境.
code-first entity-framework-4 asp.net-mvc-3 mvc-mini-profiler
我正在使用mvc-mini-profiler和Glimpse.问题是glimse充斥着探查器输出和glimpse请求.有没有办法忽略所有瞥见的请求?
我真的很喜欢我见过的有关MvcMiniProfiler的内容.我喜欢在非Web应用程序(Windows服务,单元测试等)上使用SQL监视功能.这可能,还是需要HTTP环境?明显的区别是结果传递,但如果我可以将结果序列化为JSON或某些,那就没问题了.
我把一个简单的单元测试放在一起试图让它工作,但MiniProfiler.Current似乎总是为空,即使在执行之后MiniProfiler.Start().
我在这里吠叫错了吗?
编辑 在这里得到答案
所以我想查看MiniProfiler来解决一些性能问题.在将其用于生产代码之前,我想尝试使用样本,然后继续创建MVC 5应用程序.这是使用模板创建的普通香草应用程序.
在HomeController的Index()方法中添加了此代码:
var profiler = MiniProfiler.Current;
using (profiler.Step("Set page title"))
{
ViewBag.Title = "Home Page";
}
using (profiler.Step("Doing complex stuff"))
{
using (profiler.Step("Step A"))
{ // something more interesting here
Thread.Sleep(100);
}
using (profiler.Step("Step B"))
{ // and here
Thread.Sleep(250);
}
}
return View();
Run Code Online (Sandbox Code Playgroud)
在_Layout中的jquery包下面添加了这一行:
@Scripts.Render("~/bundles/jquery")
@StackExchange.Profiling.MiniProfiler.RenderIncludes()
@Scripts.Render("~/bundles/bootstrap")
@RenderSection("scripts", required: false)
Run Code Online (Sandbox Code Playgroud)
跑了应用程序.什么都没有出现.没有剖析,没有.
我错过了什么?
问候.
asp.net-mvc ×4
.net ×1
asp.net ×1
asp.net-core ×1
c# ×1
code-first ×1
glimpse ×1
iis-6 ×1
linq-to-sql ×1
miniprofiler ×1