2/5/2018 10:15:25 PM / By: Administrator
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:
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
RazorGenerator -> download it and install
Step b: Download and install razor generator using nuget
Or By Console command:
After installing Razor Generator, it will add the below:
Step c: .csproj changes:
BeforeBuildtarget 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>
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:
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:
2/5/2018 10:15:25 PM
1/1/0001 12:00:00 AM