asp.net-mvc-3 - 第一页加载缓慢 - ASP.NET MVC

标签 asp.net-mvc-3 entity-framework ninject mvc-mini-profiler

我为我的页面使用了 miniprofiler,因为我认为我的第一页和其他一些页面的加载时间很长。我开始使用 miniprofiler,但我认为它是非常好的工具。我有这个结果:

  • http://localhost:50783/ 192.2 +0.0
    • 从数据库中获取文章 2.2 +186.9
    • 查找:索引 866.4 +190.9
    • 渲染:索引 1839.0 +1058.1
      • 查找:_Article 530.0 +2809.0
      • 渲染部分:_Article 64.3 +3339.2
      • 渲染部分:_Article 8.2 +3404.2
      • 渲染部分:_Article 12.5 +3413.0
      • 渲染部分:_Article 8.7 +3426.2
      • 渲染部分:_Article 7.9 +3435.4
      • 渲染部分:_LeftMenu 64.8 +3520.4
      • 渲染部分:_LogOnPartial 3.3 +3556.3
      • 渲染部分:_RightMenuTest 2530.1 +3591.2
      • 渲染部分:_NextMatch 3.5 +4088.7
      • 渲染部分:_Standings 4.7 +4226.5
      • 渲染部分:_Footer 21.2 +6137.4

任何人都可以帮助我减少查找时间吗?这是什么意思?我知道 RightMenuTest 的时间最长,我也在努力减少它。我在那里有很多自己的助手,我认为这是部分 View _RightMenuTest 的问题。所以我需要帮助减少其他时间。

谢谢

编辑:

_文章:

@model SkMoravanSvitavka.Models.Article
<h3>@Html.ActionLink(Model.Title, "Zobrazit", "Clanek", new { id = Model.ArticleID }, null)</h3>

    <p>@Html.Raw(Html.ArticleImageToSmall(Html.Article(Model.Text))) </p>

@Html.ActionLink("Počet komentářů:" + Model.Comments.Count, "Zobrazit", "Clanek", new { id = Model.ArticleID }, null)

文章的索引 View :

@model IEnumerable<SkMoravanSvitavka.Models.Article>
@{
    ViewBag.Title = "Sk Moravan Svitávka - oficiální stránky fotbalového klubu";
}
@if (Model != null)
{
    foreach (var item in Model)
    {
        @Html.Partial("_Article", item);
    }
}

文章 Controller 中的索引:

public ActionResult Index()
        {
            var profiler = MiniProfiler.Current;
            using (profiler.Step("Getting articles from database"))
            {
                var model = repo.GetLatestArticles(5);
                return View(model);
            }
        }

最佳答案

尝试使用 RenderPartial 代替 Partial:

foreach (var item in Model)
{
    Html.RenderPartial("_Article", item);
}

关于asp.net-mvc-3 - 第一页加载缓慢 - ASP.NET MVC,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11519205/

相关文章:

c# - 您可以使用 AWS Toolkit for Visual Studio 发布到现有的 Amazon EC2 实例吗?

entity-framework - EF Core 3 具有值(value)生成器

c# - 更改 Entity Framework 生成的中间表的表模式

c# - EF 代码优先 : Only set the foreign key(ID) and get a null collection of navigation property

c# - Ninject 和静态类 - 如何?

.net - 我可以仅针对这种特定情况在 Ninject 中指定范围吗?

c# - 使用编辑器模板处理可空类型

asp.net-mvc-3 - 包含路径表达式必须引用在类型上定义的导航属性

c# - 如何从 ASP.NET MVC 3 设置 HTTP 状态代码?

.net - 将 IOC 容器复古安装到 Brownfield Enterprise .net 应用程序