4
How can I have greater performance to render my pages using ASP.NET MVC ?
4
How can I have greater performance to render my pages using ASP.NET MVC ?
5
The rendering performance of a View is related to a number of aspects:
View
and in the Layout of View
.There is no roadmap to improve canonical performance, but I can try to gather in this response a number of measures to improve the performance of your Views
:
ViewEngines
that will not be usedIn your file Global.asax.cs
, use the following commands:
ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new RazorViewEngine());
For this case, you will only use Razor. If you are using Webforms, use:
ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new WebFormViewEngine());
[OutputCache]
for static pagesFor example:
public class HomeController : Controller
{
[OutputCache]
public ActionResult Index()
{
return View();
}
}
If the page changes little, caching it can be a good solution to avoid using the rendering engine when this is not necessary.
When publishing your system in production, make sure that your Web.config
have noted the following:
<compilation targetFramework="4.0" debug="false">
Views
who use a lot of dependent informationThis is valid for systems using some lazy load database framework (Lazy Load), such as the Entity Framework and nhibernate.
For example, if I carry a Person (usually an entity with a lot of aggregated data), I must hasten the load of information, preventing the Lazy Load cause a bottleneck in performance.
var pessoa = context.Pessoas.Include(p => p.Enderecos)
.Include(p => p.Telefones)
.Include(p => p.Compras)
.Include(p => p.Dependentes)
.Single(p => p.PessoaId == pessoaId);
Browser other questions tagged asp.net-mvc asp.net-mvc-5
You are not signed in. Login or sign up in order to post.
Because of debug="false"?
– Diego Zanardo
debug="false"
removes the Debug information, which consumes some processing to be included in the request.– Leonel Sanches da Silva
@Ciganomorrisonmendez when compiling in "release" he already puts debug=false no?
– Premiere
Depends on configuration. If Web.config undergoes transformation, yes.
– Leonel Sanches da Silva