none
Displaying Views and PartialViews takes a lot of time on first load RRS feed

  • Question

  • Hi we’re having performance issues with MVC View engine on displaying views.

    The view engine takes a lot of time to display views on first time only. Displaying views can take up to 10 seconds on first load and then less than a 100 ms.

    We are using .NET Framework 4.6.2

    Here is what we've tried so far.

    We've implementeed a basic RazorViewEngine to only look for cshtml files.

    using System.Web.Mvc;

    namespace XXXXXXX

    {

        public class CustomViewEngine : RazorViewEngine

        {

            public CustomViewEngine()

            {

                ViewLocationFormats = new[] {

                    "~/Views/{0}.cshtml",

                    "~/Views/{1}/{0}.cshtml",

                    "~/Views/Shared/{0}.cshtml"

                };

                PartialViewLocationFormats = new[] {

                    "~/Views/{0}.cshtml",

                    "~/Views/{1}/{0}.cshtml",

                    "~/Views/Shared/{0}.cshtml"

                };

            }

        }

    }

    We've removed the default view engine and added the custom view engine.

    in Global.asax.cs

    ViewEngines.Engines.Clear();

    ViewEngines.Engines.Add(new CustomViewEngine());

    We are using the RazorGenerator tools and nuget package to precompile our views.

    Have you ever seen that problem and do you know how to fix it?

    Do you know if that delay on first load is caused by slow rendering, seek time to find the view, wrong project configuration…?

    Thanks a lot for your help.

    • Moved by Sabah ShariqMVP Monday, March 12, 2018 7:15 PM Moved From Visual C#
    Monday, March 12, 2018 4:55 PM

All replies

  • Hi David,

    This is Visual C# forum. As your issue is related to Web, please ask your question into ASP.Net forum for getting quick response. I am moving your thread to off-topic.

    https://forums.asp.net/

    Your understanding and cooperation will be grateful.

    Thanks,
    Sabah Shariq

    [If a post helps to resolve your issue, please click the "Mark as Answer" of that post or click Answered "Vote as helpful" button of that post. By marking a post as Answered or Helpful, you help others find the answer faster. ]

    Monday, March 12, 2018 7:15 PM
  • The MVC forum is in the ASP.NET forums.

    http://forums.asp.net/

    Monday, March 12, 2018 7:15 PM