MVC pages slow on first view

后端 未结 2 531
无人及你
无人及你 2021-01-21 03:02

I have a simple application with MVC pages that have no javascript, images or anything other than HTML and Razor C# code (not much). Seems to me that when the pages first load t

相关标签:
2条回答
  • 2021-01-21 03:39

    Understanding ASP.NET Dynamic Compilation

    0 讨论(0)
  • 2021-01-21 03:53

    The first time a Razor view is loaded it's parsed and compiled into a C# class (by default, into a derived type of WebViewPage or WebViewPage), and the view is actually compiled into the Execute Method of that class. Something similar actually happend with old WebForms pages too.

    There are also other things in the MVC pipeline that degrade performance on the first call, like the application_start (if it's also the first request for the application), and some other operations with reflection,dependency resolution and other operations that only happen on the first call (they're cached for subsequent calls),.

    0 讨论(0)
提交回复
热议问题