标签: mvc-mini-profiler

仅为特定用户和角色启用迷你探查器

在asp.net mvc中,scott hanselman示例演示了如何显示本地环境的迷你探查器

protected void Application_BeginRequest()
        {
            if (Request.IsLocal) { MiniProfiler.Start(); } //or any number of other checks, up to you 
        }
Run Code Online (Sandbox Code Playgroud)

但是,我想更进一步,能够远程查看它,仅针对特定的登录用户或ips.

知道怎么样?

更新:我使用了以下代码:

protected void Application_EndRequest()
        {
            MiniProfiler.Stop(); //stop as early as you can, even earlier with MvcMiniProfiler.MiniProfiler.Stop(discardResults: true);
        }

        protected void Application_PostAuthorizeRequest(object sender, EventArgs e)
        {
            if (!IsAuthorizedUserForMiniProfiler(this.Context))
            {
                MiniProfiler.Stop(discardResults: true);
            }
        }

        private bool IsAuthorizedUserForMiniProfiler(HttpContext context)
        {
            if (context.User.Identity.Name.Equals("levalencia"))
                return true;
            else
                return context.User.IsInRole("Admin");
        }
Run Code Online (Sandbox Code Playgroud)

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

2
推荐指数
1
解决办法
689
查看次数

无法使用 Miniprofiler 打印查询

我在我的项目中集成了 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)

.net c# mvc-mini-profiler miniprofiler

2
推荐指数
1
解决办法
1620
查看次数

mvc mini profiler - IIS7问题

类似于这个问题mvc mini profiler(1.4)和IIS

我正在运行IIS 7.5,我的应用程序池在Webforms站点上以集成模式运行

当对迷你探查器包含文件的请求发生时,我得到了一堆404错误?

我唯一改变的是我删除了MVChelpers文件夹和MVC参考,因为我们没有在我们的网站上安装它们.

它在VS2010上运行良好

我需要做些什么才能解决这个问题?

谢谢

asp.net iis-7 iis-7.5 mvc-mini-profiler

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

Stack Overflow的MVC mini分析器(安装)

我已经下载了迷你探查器:http: //code.google.com/p/mvc-mini-profiler/

我正在使用带有webforms的ASP.net 4.0(VS 2010).我真的很困惑如何安装它.我已经打开了下载中包含的各种项目,大多数都没有打开没有错误.

我有点期待一个DLL只是包括,但这显然是错误的!我搜索了安装说明但找不到任何安装说明.

谁能帮帮我吗?

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

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