MVC查找或呈现视图性能问题

时间:2013-12-19 08:43:45

标签: c# asp.net-mvc performance asp.net-mvc-routing render

我在查找或渲染视图时遇到“大”(每次请求首次请求500毫秒)性能问题。 经过互联网的多次搜索后,我发现如何避免查找视图的性能问题,但问题推迟到渲染部分...... 最后,我仍然有500毫秒的差距来呈现一个简单的视图。

我没有发现我的控制器的大小是否有问题(15k代码行),或者它是否与我的视图完全相关(内部有服务器代码,不是很多,但可能很重要吗?)

感谢您的帮助!

编辑:路由配置

protected void Application_Start()
    {
        ViewEngines.Engines.Clear();
        CustomRazorViewEngine engine = new CustomRazorViewEngine() {
            AreaViewLocationFormats = new[] { "~/Areas/{2}/Views/{1}/{0}.cshtml", "~/Areas/{2}/Views/Shared/{0}.cshtml" },
            AreaMasterLocationFormats = new[] { "~/Areas/{2}/Views/{1}/{0}.cshtml", "~/Areas/{2}/Views/Shared/{0}.cshtml" },
            AreaPartialViewLocationFormats = new[] { "~/Areas/{2}/Views/{1}/{0}.cshtml", "~/Areas/{2}/Views/Shared/{0}.cshtml" },
            ViewLocationFormats = new[] { "~/Views/{1}/{0}.cshtml", "~/Views/Shared/{0}.cshtml" },
            MasterLocationFormats = new[] { "~/Views/{1}/{0}.cshtml", "~/Views/Shared/{0}.cshtml" },
            PartialViewLocationFormats = new[] { "~/Views/{1}/{0}.cshtml", "~/Views/Shared/{0}.cshtml" },
            FileExtensions = new[] { "cshtml" }
        };  
        engine.ViewLocationCache = new DefaultViewLocationCache(TimeSpan.FromHours(24));
        ViewEngines.Engines.Add(new ProfilingViewEngine(engine));
        AreaRegistration.RegisterAllAreas();
        RegisterGlobalFilters(GlobalFilters.Filters);
        RegisterRoutes(RouteTable.Routes);

        ModelBinders.Binders.Add(typeof(double?), new DoubleModelBinder());
        ModelBinders.Binders.Add(typeof(double), new DoubleModelBinder());

    }

0 个答案:

没有答案