标签: mvc-mini-profiler

MVC Mini Profiler包括不尊重应用程序的路径

我已经按照项目页面上的描述设置了MVC Mini Profiler ,并且确实正在页面上编写包含.

问题是,我的应用程序位于http://localhost:8080/web,并且分析器编写的标记包括如下所示:

<link rel="stylesheet/less" type="text/css" href="/mini-profiler-includes.less?v=2.0.4177.17902">
<script type="text/javascript" src="/mini-profiler-includes.js?v=2.0.4177.17902"></script>
<script type="text/javascript"> jQuery(function() { MiniProfiler.init({ id:'fb4dc30e-c1aa-4be6-902c-ef2812dd1fe2', renderDirection:'left' }); } ); </script>
Run Code Online (Sandbox Code Playgroud)

这些当然都会给出404错误,但是如果我导航到/web/mini-profiler-includes.less?它,它会很好地加载.

可以在此处找到创建该字符串的源:

// MiniProfilerHandler.cs
/// <summary>
/// Understands how to route and respond to MiniProfiler UI urls.
/// </summary>

public class MiniProfilerHandler : IRouteHandler, IHttpHandler
{
    internal static HtmlString RenderIncludes(MiniProfiler profiler, RenderPosition? position = null, bool showTrivial = false, bool showTimeWithChildren = false)
    {
        const string format =
            @"<link …
Run Code Online (Sandbox Code Playgroud)

asp.net asp.net-mvc .net-4.0 mvc-mini-profiler

11
推荐指数
1
解决办法
1568
查看次数

MiniProfiler与EF"模型第一"edmx模型

我正在尝试让MiniProfiler配置我的数据库访问,但我遇到了问题.我看到的所有帮助似乎都是"代码优先"实体框架连接.我的模型是在今年代码第一次更新可用之前设计的,我使用设计器来创建edmx模型.(我已经使用了近一年,它似乎对我有用)

MiniProfiler文档站点上的示例对我没有意义.我尝试了一些变体,但我遇到了问题.

我的模型被称为CYEntities,通常是为了实例化一个ObjectContext我就是这样做的,这 var context = new CYEntities()是我为探查器试过的...

var dbConnection = new CYEntities().Connection;
var profiledConnection = ProfiledDbConnection.Get(dbConnection);
var context = profiledConnection.CreateObjectContext<CYEntities>(); // this is the context I'd finally use to access data. 
Run Code Online (Sandbox Code Playgroud)

这引发了异常......

System.ArgumentException:无法找到请求的.Net Framework数据提供程序.它可能没有安装.

我不知道从哪里开始.

asp.net-mvc asp.net-mvc-3 mvc-mini-profiler

11
推荐指数
2
解决办法
865
查看次数

如何隐藏miniprofiler?

我正在使用MVC Mini分析器来检查我的应用程序的特定部分的速度,并希望将其保留在那里以防万一发生以后的事情,我可能需要检查"出了什么问题".它不是一个完整的日志集,但它非常方便地知道什么使页面花了很长时间.

因此,我的目标是隐藏它并仅在请求带有特定参数时才对其进行配置.但是,我的尝试都没有像我期望的那样奏效.

这已经完成了不在屏幕上显示它的技巧(视图中的代码):

@if (Request.QueryString.AllKeys.Contains("showProfiler"))
{ 
    @MvcMiniProfiler.MiniProfiler.RenderIncludes()
}
Run Code Online (Sandbox Code Playgroud)

这是接近的尝试.正确隐藏迷你探查器信息,但是在我显示它的那一刻,它会描述所有内容,因为我停止显示它.所以,假设我描述了我的页面,需要3秒钟.我删除了查询参数并再次加载页面三次.我再次添加我的参数,我看到4组配置文件信息.这意味着它会记录所有内容,我想知道它是否会给内存带来问题.

尝试不再发生这种情况:

尝试1:

protected void Application_BeginRequest()
{
    if (Request.QueryString.AllKeys.Contains("showProfiler"))
    {
        MiniProfiler.Start();
    }
}
Run Code Online (Sandbox Code Playgroud)

尝试2:

protected void Application_EndRequest()
{
    MiniProfiler.Stop(!Request.QueryString.AllKeys.Contains("showProfiler"));
}
Run Code Online (Sandbox Code Playgroud)

尝试3:

protected void Application_EndRequest()
{
    MiniProfiler.Stop(true);
}
Run Code Online (Sandbox Code Playgroud)

这些都没有奏效.有任何想法吗?

c# profiling asp.net-mvc-3 mvc-mini-profiler

11
推荐指数
1
解决办法
4118
查看次数

StructureMap DBServiceRegistry和MVC-mini-profiler?

如果我在每个Repository类中使用此代码,那么我可以使SQL分析工作,但我想将每个类的代码移动到StructureMap处理DB的类中.

存储库类的示例:

public DB CreateNewContext()
    {
        var sqlConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["connection"].ConnectionString);
        var profiledConnection = ProfiledDbConnection.Get(sqlConnection);
        return DataContextUtils.CreateDataContext<DB>(profiledConnection);
    }

    public SqlRecipeRepository(DB dataContext)
    {         
        _db = CreateNewContext();
    }
Run Code Online (Sandbox Code Playgroud)

现在我想将dataContext变量作为配置文件版本,因此来自我的DBServiceRegistry类.

这是DBServiceRegistry类:

public class DBServiceRegistry : Registry
{
    public DBServiceRegistry()
    {
        var sqlConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["GetMeCooking.Data.Properties.Settings.server"].ConnectionString);
        var profiledConnection = ProfiledDbConnection.Get(sqlConnection);
        For<DB>().HybridHttpOrThreadLocalScoped().Use(() => DataContextUtils.CreateDataContext<DB>(profiledConnection));

        //Original method just had this:
        //For<DB>().HybridHttpOrThreadLocalScoped().Use(() => new DB());

    }
}
Run Code Online (Sandbox Code Playgroud)

这段代码不会导致任何错误,但我没有得到SQL分析,我做错了什么?

structuremap linq-to-sql mvc-mini-profiler

10
推荐指数
1
解决办法
371
查看次数

我们用v1.9获得"a.tmpl.complete不是函数"

我们在分析器的v1.9中收到以下错误.

a.tmpl.complete不是一个函数

搜索并试图调查问题,但到目前为止没有运气如何纠正它.

其他人都知道该怎么办?

mvc-mini-profiler

10
推荐指数
1
解决办法
497
查看次数

MvcMiniProfiler可以显示SQL参数值吗?

我一直在试用MvcMiniProfiler作为替代EFTracingProvider,因为它是如此更容易配置.

它会显示sql很好,但我也希望看到参数值.

insert [dbo].[PersonName]([Prefix], [GivenName], [MiddleName], [FamilyName], [Affix])
values (@0, @1, @2, @3, @4)
select [Id]
from [dbo].[PersonName]
where @@ROWCOUNT > 0 and [Id] = scope_identity()
Run Code Online (Sandbox Code Playgroud)

MvcMiniProfiler可以显示sql参数值吗?

这是我的Global.asax.我正在使用EF 4.3.1代码优先.

protected void Application_Start()
{
    Bootstrapper.Initialize();

    AreaRegistration.RegisterAllAreas();

    RegisterGlobalFilters(GlobalFilters.Filters);
    RegisterRoutes(RouteTable.Routes);

    MiniProfilerEF.Initialize();
}

protected void Application_BeginRequest()
{
    if (Request.IsLocal)
    {
        MiniProfiler.Start(ProfileLevel.Verbose);
    }
}

protected void Application_EndRequest()
{
    MiniProfiler.Stop();
}
Run Code Online (Sandbox Code Playgroud)

entity-framework ef-code-first mvc-mini-profiler

10
推荐指数
1
解决办法
1085
查看次数

将MiniProfiler连接到ASP.NET Core Web API Swagger

我发现只有本手册描述了如何使的ASP.NET Web API和UI扬鞭工作MiniProfiler,但我没有看到一个描述如何使ASP.NET核心与MiniProfiler的Web API的工作,以显示扬鞭UI结果的任何手册.

c# mvc-mini-profiler swagger-ui asp.net-core asp.net-core-webapi

10
推荐指数
1
解决办法
2419
查看次数

而且,ASP.NET MVC Content文件夹的神奇之处是什么?

我刚刚将资源文件(javascript,css,images)从Content文件夹移动到自定义Assets文件夹.我注意到一个奇怪的行为 - 这些文件不再被浏览器缓存,MvcMiniProfiler显示对位于Assets文件夹中的每个资源的单独请求:

在移动到Assets文件夹之前和之后

我知道ContentASP.NET MVC约定不需要该文件夹,但为什么会发生这种情况?被Content莫名其妙地治疗尤其是人(如ASP.NET,IISExpress等)?以及如何强制缓存包含静态资源的其他文件夹?

编辑:哦,它似乎不是一个ASP.NET MVC奇怪的行为,但只是MvcMiniProfiler的标准行为.目前我正在检查......

编辑:是的,ASP.NET MVC没有问题,它只是MvcMiniProfiler 的默认配置,只能忽略这些路径:"/mini-profiler-", "/content/", "/scripts/", "/favicon.ico".这些默认值可以很容易地扩展:

MiniProfiler.Settings.IgnoredPaths = MiniProfiler.Settings.IgnoredPaths
    .Concat(new [] { "/assets/" })
    .ToArray();
Run Code Online (Sandbox Code Playgroud)

有时在使用之前阅读文档是个好主意;)

asp.net-mvc caching asp.net-mvc-routing mvc-mini-profiler

9
推荐指数
2
解决办法
1407
查看次数

ASP.NET MVC MiniProfiler和EntityFramework 6初始化

我有一个类似的问题,在加载MiniProfiler和MiniProfiler.EnitiyFramework6后我有这个问题.MiniProfiler运行正常,但是当我在Global.asax中添加到我的Applcation_Start时

MiniProfilerEF6.Initialize();

我明白了:

MiniProfiler.EntityFramework6.dll中出现"System.IO.FileLoadException"类型的异常,但未在用户代码中处理

附加信息:无法加载文件或程序集'MiniProfiler,Version = 3.0.11.0,Culture = neutral,PublicKeyToken = b44f9351044011a3'或其依赖项之一.定位的程序集的清单定义与程序集引用不匹配.(HRESULT异常:0x80131040)

asp.net-mvc mvc-mini-profiler

9
推荐指数
1
解决办法
2817
查看次数

MiniProfiler:如何配置AngularJS + WebAPI应用程序?

在MiniProfiler社区上交叉发布.

我正在尝试将MiniProfiler放入我当前的堆栈中.我认为我主要是设置,但我错过了UI方法,并希望得到关于最佳方法的建议.

当前堆栈

  • SQL for DB(包括MiniProfiler表)
  • EF 6
  • WebAPI 2 API应用程序
  • Angular 1.x. 用户界面的应用程序(单独的应用程序,没有MVC支持它) - 我认为此时它是1.5.x.

所以,目前的方法RenderIncludes()是我无法获得的.

包含JS文件并将其设置为从SQL Server存储中检索信息的最佳方法是什么?我知道这些文件包含在UI repo中,但我没有看到用于显式配置的文档.

我到目前为止所尝试的内容 - Web API应用程序

  • 安装MiniProfilerMiniProfiler.EF6包.

Web.Config - 添加了Handler

(不确定是否有必要):

<add name="MiniProfiler" path="mini-profiler-resources/*" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" />
Run Code Online (Sandbox Code Playgroud)

添加了CORS过滤器以将MiniProfiler ID公开给我的客户端应用程序:

public class AddMiniProfilerCORSHeaderFilter : ActionFilterAttribute
{
    public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
    {
        actionExecutedContext.Response.Headers.Add("Access-Control-Expose-Headers", "X-MiniProfiler-Ids");
    }
}
Run Code Online (Sandbox Code Playgroud)

添加该过滤器作为启动的一部分:

config.Filters.Add(new AddMiniProfilerCORSHeaderFilter());`
Run Code Online (Sandbox Code Playgroud)

在Global.asax中,添加到Application_Start():

var connectionString = ConfigurationReader.GetConnectionString(Constants.ConfigSettings.CONNECTION_STRING_NAME);

MiniProfiler.Settings.Storage = new SqlServerStorage(connectionString);
MiniProfilerEF6.Initialize();
Run Code Online (Sandbox Code Playgroud)

更新开始/结束请求:

   protected void …
Run Code Online (Sandbox Code Playgroud)

mvc-mini-profiler asp.net-web-api angularjs asp.net-web-api2

9
推荐指数
1
解决办法
1166
查看次数