How To Optimize Asp.Net Application ?
Dot Net Training
In this article, we will walk via some performance improvement techniques in ASP.NET Web Applications. It’s universal that customer expects the good performance of a web application. Basically, large-scale Web applications are deployed to load-balancing servers to share traffic evenly across a number of application servers. Additional application servers are added without making any further changes to the application. The application server might enhance Web application performance; however, there are ways to improve performance on the developer side as well. You can follow certain optimization techniques when you code that can reduce a lot of performance issues. It is essential to know which parts code or code parts can be optimized, and how you can measure improvements in performance.
Dot Net Training
Here we share a number of optimization techniques that you can use: Discard objects from the caller method than in the called method. Use connection pooling such that the connections can be re-used during requirement of future requests to the database.
Delete white spaces and extra tags to reduce the size of your pages. Make limited use of graphics and consider using compressed graphics. Reduce page load times by minimizing the scripts. Use cascading style sheets to avoid repeated sending of the same formatting directives to the client. Use short control names because they generate unique HTMLID names. Minimize redundant processing by using Page.IsPostBack . Use for each loop instead of a for loop if possible. Avoid using ViewState to facilitate faster page loads.
Dot Net Training
Cache the Web pages or a portion if the page is large. Use data caching for improving the application performance instead of fetching data from a file or database. Data is stored in the memory of Datasets hence write efficient SQL queries or procedures that fetch only the required information. So not use Page.DataBind. Instead, code data bind on specific controls because the page-level method calls the DataBind method of every control on the page that supports data binding. Use minimal, call to DataBinder.Eval because this method uses reflection to access the arguments that are passed in and to return the results. For example, if a page has a table of 50 rows and 10 columns, DataBinder.Eval will be named 500 times if you use DataBinder.Eval on each column. Instead, use clear casting offers better performance by keeping away the cost of reflection. Cast the Container.DataItem as a DataRowView, as shown in the following code . Dot Net Training
<ItemTemplate> <tr> <td><%# ((DataRowView)Container.DataItem) ["First_Name"] %></td> <td><%# ((DataRowView)Container.DataItem) ["Last_Name"] %></td> </tr></ItemTemplate> You can achieve better performance with clear casting if you use a DataReader to bind your control and use the special methods to retrieve your data. Cast the Container.DataItem as a DbDataRecord. <ItemTemplate> <tr> <td><%# ((DbDataRecord)Container.DataItem) .GetString(0) %></td> <td><%# ((DbDataRecord)Container.DataItem) .GetInt(1) %></td> </tr></ItemTemplate>
Dot Net Training
Disable useless session states because ASP.NET Manages a session state by default and lessens the cost in memory when you don’t use it. For example, if your pages are fixed or when you don’t require to store information captured in the page. <@%Page EnableSessionState=”false”%> make read only session state for retrieving data <@%Page EnableSessionState =”ReadOnly”%> Turn off tracing unless needed. <trace enabled=”false” requestLimit=”8″ pageoutput=”false” traceMode=”SortByTime” localOnly=”true”> Use SqlDataReader to visit the read-only data and not DataSet. You can return multiple result sets by using dynamic SQL, it is preferable to utilize stored procedures to get multiple result sets Dot Net Training
Using gzip compression can reduce the number of bytes sent by the server. This helps faster page loads and also cuts down on bandwidth usage. If you got a bunch of .NET Web services running in one IIS Application and utilized by another IIS application, the first call to Web services, in most cases, might be pretty slow. To speed up the initial call, you can create the XmlSerializers DLL at compile time. Hope the above-mentioned points would help you to code at ease. If you want to learn ASP.Net and perfect yourself in .NET training, then CRB Tech Solutions would be of great help and support for you. Join us with our updated program in ASP.Net course. Stay tuned to CRB Tech reviews for more technical optimization and other resources.
Dot Net Training
Thank You..!
Dot Net Training