Friday, January 4, 2013

How to Improve ASP.NET Performance

Yesterday I had an interview for the senior software engineer at xxx company :) One interview question leads me to write this post. The question was,

If there is an ASP page with a grid which will contain a millions of data on it, how do you going to improve the performance?

At that circumstance I can only think about the pagination as I haven't even think about such situation before. :) So I try to tell about pagination in different ways. such as by having page numbers at the bottom of the grid, or load data accordingly when scrolling the page etc.. :)
All are correct but not the exact answer. Finally he given me the answer. It was

By Disabling the View State.

Then I have a problem about, Why is that correct? ( I can't again ask that from the interviewer.. :) so I kept that in my mind and return back to home.)

Actually If the page doesn't have any user inputs and no point of having view state. So we can simply disable that. It will save CPU Time to build the view state.

Then you will have a problem about, How to disable the View State?

This is how each page's header looked after the change:

<%@ Page EnableViewState=”false”...%>

This is pretty simple change for ASP.NET mark up, So no rebuild required.

And also I like to mention another point here.
If you are accessing the session only for reading in some pages you can set the EnableSessionState for ReadOnly. It's again improve the performance of the page.
This is how you do both at the page header

<%@ Page EnableViewState=”false”EnableSessionState=”ReadOnly” ...%>

Here is the link for get more deep idea about Improving .NET Application Performance and Scalability

Hope this will help you.

No comments:

Post a Comment