2/5/2018 10:15:25 PM
In this tip, I explain how we can optimize the ASP.NET MVC application performance.
Currently, we are working on very large applications consisting of a number of projects which takes more time to build solution, startup time as well as overall application running time. We have different levels of performance optimization in a web application as below:
In this tip, I am sharing my views for these three levels of optimization that I've been applying in my applications.
There are multiple things that we can do for optimizing the application performance. Apart from the technical part, we can also configure AppPool as below:
Configure AppPool
as Suspended
and AlwaysRunning
as shown below:
Right click on AppPool -> Advance Settings:
It will optimize the time by 20-30%.
Suppose a web application takes approximately 3 minutes to build so each time we change a line of code, we must wait for 3 minutes. Build time should not be >1 minute. If it is, then we should optimize it by applying the following steps:
You can refer to the below link for using Razor Generator.
Step a: Go to Tools -> Extension and updates
Search for RazorGenerator
-> download it and install
Step b: Download and install razor generator using nuget
RazorGenerator.Mvc
RazorGenerator.MsBuild
Or By Console command:
PM> Install-Package RazorGenerator.Mvc
PM> Install-Package RazorGenerator.MsBuild
After installing Razor Generator, it will add the below:
RazorGenerator.MsBuild
RazorGenerator.Mvc
WebActivatorEx
Step c: .csproj changes:
BeforeBuild
target code right after the previously added line to import the RazorGenerator.targets file:
<Target Name="BeforeBuild"> <ItemGroup> <Content Remove="Views\**\*.cshtml" /> <None Include="Views\**\*.cshtml" /> </ItemGroup> </Target>
<PrecompileRazorFiles>true</PrecompileRazorFiles>
<MvcBuildViews>false</MvcBuildViews>
Now Build application, .cs files will be created for cshtml views under /obj/CodeGen/.
<Compilation debug="true" targetFramework="4.5" optimizeCompilations="true"/>
AppStart
time is after rebuilding solution, first page loads time.
From a development point of view, appstart
time should be as minimum as possible. In a large application, whenever we change a single line of code and run the app after rebuild, a developer must wait for 2-3 minutes.
We can try the following:
ContainerControlledLifetimeManager
).For easy development, build time and appstart
time should be minimum, otherwise developers have to wait unnecessarily for long for a single line code change.
You can also take a look at my other tips:
Administrator
2/5/2018 10:15:25 PM
1/1/0001 12:00:00 AM
https://yoong.vn/