MVC页上的第一个视图慢 [英] MVC pages slow on first view

查看:78
本文介绍了MVC页上的第一个视图慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对此没有JavaScript,图片或任何比HTML和剃刀C#code(不要太多)其他MVC页面的简单应用程序。在我看来,当页面第一次加载,他们需要很长的时间,在那之后他们快得多。有一些编译第一次请求页面的事情与MVC3。

罗伯特


<格CLASS =h2_lin>解决方案

第一次的Razor视图被加载它的解析和编译成C#类(默认情况下,成为一个派生类型WebViewPage或WebViewPage的),视图实际上编译成类的执行方法。类似的事情其实与旧的WebForms页面太happend。

也有在MVC管道其他的事情,降低在第一次通话性能,像的Application_Start(如果它也是应用程序的第一个请求),并与反思,依赖解析等操作一些其他的操作,只有发生在第一次调用(他们缓存的后续调用),.

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 they take a long time and then after that they are much quicker. Is there some compilation going on with MVC3 the first time a page is requested.

Robert

解决方案

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),.

这篇关于MVC页上的第一个视图慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆