标签: mvc-mini-profiler

MvcMiniProfiler结果请求在Asp.Net MVC应用程序中提供404

我试图在我的Asp.Net MVC应用程序中使用MvcMiniProfiler.我安装了最新的NuGet包,并从wiki页面添加到所有的代码Application_BeginRequest(),Application_AuthenticateRequest()并在我的观点.

加载页面后,所有迷你探查器的javascript文件都被包含在内并从服务器上正确下载,但当它尝试获取结果时Chrome显示:

GET http://localhost:59269/mini-profiler-results?id=59924d7f-98ba-40fe-9c4a-6a163f7c9b08&popup=1 404 (Not Found)
Run Code Online (Sandbox Code Playgroud)

我认为这是由于没有设置MVC的路由允许/mini-profiler-results但是我找不到办法做到这一点.查看Google代码页,他们Global.asax.cs的示例应用程序的文件经历了多次更改,一次使用MvcMiniProfiler.MiniProfiler.RegisterRoutes(),第二次使用MvcMiniProfiler.MiniProfiler.Init(),第三种样式不执行任何操作.前面提到的两个函数不存在,所以我假设它们已被逐步淘汰.

在这一点上,我不确定如何修复此错误并在我的应用程序中使用分析器.有任何想法吗?


我的Global.Asax.cs文件如下所示:

public class Global : System.Web.HttpApplication
{
    protected void Application_BeginRequest()
    {
        MvcMiniProfiler.MiniProfiler.Start();
    }

    protected void Application_AuthenticateRequest(Object sender, EventArgs e)
    {
        // Only show profiling to admins
        if (!Roles.IsUserInRole(Constants.AdminRole))
            MvcMiniProfiler.MiniProfiler.Stop(discardResults: true);
    }

    protected void Application_Start(object sender, EventArgs e)
    {
        AreaRegistration.RegisterAllAreas();
        RegisterRoutes(RouteTable.Routes);
    }

    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
        routes.IgnoreRoute("{resource}.aspx/{*pathInfo}");

        routes.MapRoute(
        "Default",
            // Route name
        "{controller}/{action}/{id}",
            // URL with …
Run Code Online (Sandbox Code Playgroud)

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

12
推荐指数
1
解决办法
3736
查看次数

如何将ms显示从LHS移动到RHS

显示用于显示页面的ms的小气泡.如何将其配置为在RH角而不是LH角显示.

已尝试通过global.asax进行访问设置.

能够通过改变来源来试用它

<div class="profiler-results left"></div>
Run Code Online (Sandbox Code Playgroud)

<div class="profiler-results right"></div>
Run Code Online (Sandbox Code Playgroud)

谢谢

asp.net-mvc mvc-mini-profiler

12
推荐指数
1
解决办法
645
查看次数

从System.Net.Http.DelegatingHandler调用时,MiniProfiler.Current为null

我在我的asp.net Web API项目中使用迷你探查器,并希望跟踪在自定义DelegatingHandler中运行的某些代码的性能.

MiniProfiler.Current.Step()内部的调用DelegatingHandler不会显示在结果中.同一项目中的其他调用显示正常.

进一步的调查显示,MiniProfiler.Current是从中获取HttpContext.CurrentWebRequestProfilerProvider.而HttpContext.Current从调用时为空 DelegatingHandler.

有没有更好的方法来检索MiniProfiler.Current,以便它在处理程序内部工作?

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

12
推荐指数
1
解决办法
1377
查看次数

如何在实体框架4.1中使用mvc-mini-profiler

我试图使用mvc-mini-profiler与MVC3并继续得到以下错误

无法确定连接类型为"MvcMiniProfiler.Data.ProfiledDbConnection"的提供程序名称

下面是我用来尝试和实现我的Context的代码.

DbConnection conn = new MySqlConnection(
    ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString);

var profiledConnection = MvcMiniProfiler.Data.ProfiledDbConnection.Get(conn);
return new DB(profiledConnection);
Run Code Online (Sandbox Code Playgroud)

这是DB Context Class.

public class DB:DbContext, Stats.Data.IDB
{
    public DB(DbConnection conn)
        : base(conn, true)
    {

    }...
Run Code Online (Sandbox Code Playgroud)

c# mysql entity-framework asp.net-mvc-3 mvc-mini-profiler

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

使用带有EF 4.0和Ninject的mvc-mini-profiler

我正在尝试使用基于EF4的应用程序使用新的mvc-mini-profiler,但我不知道如何正确连接到我的目标数据源.

据我所知.

Func<IMyContainer> createContainer = () =>
{
    var profiler = MiniProfiler.Current;

    if (profiler != null)
    {
        var rootConn = // ????
        var conn = ProfiledDbConnection.Get(rootConn);
        return ObjectContextUtils.CreateObjectContext<MyContainer>(conn);
    }
    else
    {
        return new MyContainer();
    }
};

kernel.Bind<IMyContainer>().ToMethod(ctx => createContainer()).InRequestScope();
Run Code Online (Sandbox Code Playgroud)

如何在没有contianer的情况下获得与EF容器的连接?我只是新建一个SqlConnection,除了连接字符串包装在所有EF垃圾中.

ninject entity-framework-4 asp.net-mvc-3 mvc-mini-profiler

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

从MVC Mini Profiler获得更多"粒度"

如果这对任何人都有用,我很乐意把它变成社区维基.

我在MVC3应用程序中有一些慢页面,并且因为我的代码中似乎很少执行时间,所以我想知道是否可以找到更多关于花了这么长时间的内容.并不是说我成功了,但我在这个过程中获得了更多的智慧.

对于拥有一些MVC经验的人来说,这里没有什么是不明显的.基本上,我创建了自己的ActionFilterAttribute,如下所示:

public class ProfilerAttribute : ActionFilterAttribute
{
    IDisposable actionStep = null;
    IDisposable resultStep = null;

    public override void OnActionExecuting(ActionExecutingContext filterContext)
    {
        actionStep = MiniProfiler.Current.Step("OnActionExecuting " + ResultDescriptor(filterContext));
        base.OnActionExecuting(filterContext);
    }

    public override void OnActionExecuted(ActionExecutedContext filterContext)
    {
        if (actionStep != null)
        {
            actionStep.Dispose();
            actionStep = null;
        }
        base.OnActionExecuted(filterContext);
    }

    public override void OnResultExecuting(ResultExecutingContext filterContext)
    {
        resultStep = MiniProfiler.Current.Step("OnResultExecuting " + ResultDescriptor(filterContext));
        base.OnResultExecuting(filterContext);
    }

    public override void OnResultExecuted(ResultExecutedContext filterContext)
    {
        if (resultStep != null)
        {
            resultStep.Dispose();
            resultStep = null;
        }
        base.OnResultExecuted(filterContext); …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc mvc-mini-profiler

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

带有OutputCacheAttribute的mvc-mini-profiler

我在测试网站上使用mvc-mini-profiler.当我在我的action方法上放置一个OutputCacheAttribute时,不会执行探查器并始终返回缓存之前的最后一个值.

有没有办法告诉mvc-mini-profiler结果来自缓存,以便它可以更新他的状态?也许在客户端网站上,我们可以看到这样的信息:

http://localhost/Home (from cache) 2.1ms,  +0.5ms 
Run Code Online (Sandbox Code Playgroud)

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

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

如何隐藏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
查看次数

用于ASP.NET网站的Miniprofiler

在此输入图像描述我怎样才能在asp.net网站上使用miniprofiler(不适用于MVC)?MVC有很多资源,但我找不到任何网站.

感谢Alex.现在它适用于asp.net网站.但我无法理解它显示的是什么.我没有在方法中编写任何代码.见下图.

代码如下,我运行了profiler.

protected void Page_Load(object sender, EventArgs e)
{
    using (MiniProfiler.Current.Step("test"))
    {
        Page.Title = "12345";
    }
}
Run Code Online (Sandbox Code Playgroud)

asp.net mvc-mini-profiler web

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

MVC4 MiniProfiler结果 - 索引页面错误"MiniProfiler.list未定义"

我在尝试加载miniprofiler列表时收到错误"MiniProfiler.list is undefined"错误:
/mini-profiler-resources/results-index

javascript miniprofiler injects没有任何名为"list"的方法或属性.

显示一个结果跟踪的页面工作正常.

我正在使用Nuget来安装软件包,删除当前版本的MiniProfiler并安装最新版本:

Install-Package MiniProfiler
Run Code Online (Sandbox Code Playgroud)

然后:

Install-Package MiniProfiler.Mvc4
Run Code Online (Sandbox Code Playgroud)

找不到其他有同样问题的人,所以一定是我!我错过了一些明显的东西吗?我还在web.config中添加了处理程序,虽然我有runAllManagedModulesForAllRequests="true"但仍然没有.

mvc-mini-profiler asp.net-mvc-4 mvcminiprofiler

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