Support us MVC ASP.NET C# SQL Server WCF Written Test HR Round Subscribe C# Videos C# Programs Buy DVD

ASP.NET Page is very slow. What will you do to make it fast


This is a very common asp.net interview question asked in many interviews. There are several reasons for the page being slow. We need to identify the cause.

1. Find out which is slow, is it the application or the database : If the page is executing SQL queries or stored procedures, run those on the database and check how long do they take to run. If the queries are taking most of the time, then you know you have to tune the queries for better performance. To tune the queries, there are several ways and I have listed some of them below.
   a) Check if there are indexes to help the query
   b) Select only the required columns, avoid Select *.
   c) Check if there is a possiblity to reduce the number of joins
   d) If possible use NO LOCK on your select statements
   e) Check if there are cursors and if you can replace them with joins

2. If the queries are running fast, then we know it is the application code that is causing the slowness. Isolate the page event that is causing the issue by turning tracing on. To turn tracing on, set Trace="true" in the page directive. Once you have tracing turned on you should see trace information at the bottom of the page as shown in the image below. In this case Page Load event is taking the maximum time. So we know, the code in Page_Load event is causing the issue. Once you look at the code, you should be able to nail down the issue.




43 comments:

  1. nice explanation its very easy to understand thank you

    ReplyDelete
  2. Another factor to slow down asp page is view-state. so developer should check view state of each control and possibly turn off unnecessary view state from certain controls. specially gridview control's view state will take much time to reload.

    ReplyDelete
  3. HI i have some question of .net which are asked to me in the interview :

    1. How to redirect to next page from J query.
    2. What are triggers.
    3. What is Form Authentication and how we use an implement it.
    4. what is passport authentication.

    ReplyDelete
    Replies
    1. Hi Atul, I have asp.net, sql server and c# video tutorial for beginners and uploaded to youtube. Triggers and Forms authentication is clearly explained in these videos. Please check the link below.
      Sql server, asp.net and csharp video tutorial

      Delete
  4. Replies
    1. It is used to add or remove assembly from GAC(Global assembly Cache)

      Delete
  5. Nice way of explaining..

    ReplyDelete
  6. The explanation is very good and crystal clear.. Thanks.

    ReplyDelete
  7. EXPLANATION IS GOOD

    ReplyDelete
  8. Other factors that may make the page slow are
    Including lots of unnecessary huge files in the page (JS/CSS)
    Use of lots of images in the page without optimizing them
    Use of unnecessary tags (div etc)

    ReplyDelete
  9. Avoid to use HTML table or Table span , in place of HTML table use DIV and class for design

    ReplyDelete
  10. very nice concept + example

    ReplyDelete
  11. easy to understand

    ReplyDelete
  12. Great Explanation...I want to add something more..
    Following are the other factors which slows down the web page.
    1. View state-If not required, disable it.
    2. Always use minified javascript.

    ReplyDelete
  13. good useful for interviews as well as fine tune the application...

    ReplyDelete
  14. i add two more thinks,

    1.check if any logs occur in sql database by using who2 stored procedure.

    2.check if more worker processor(w3wp.exe) are created in iis by using right click Taskmanger
    in web server.(kill some w3wp.exe)

    ReplyDelete
  15. sorry,some changes in first point.

    1.check if any (locks or blocking) occur in sql database
    by using
    i) who2 stored procedure.
    ii) SQL Server Management Studio Activity Monitor.

    2.check if more worker processor(w3wp.exe) are created in iis by using right click Taskmanager
    in web server.(kill some w3wp.exe)

    ReplyDelete
  16. plse answer the question which is asked in above.

    ReplyDelete
  17. its so easy language, thanks

    ReplyDelete
  18. its really nice example just try it once Trace="True"....

    ReplyDelete
  19. Cool.. this Qn was asked to me too in an interview!!

    ReplyDelete
  20. this is really helpful site Venkat. keep up the good work.

    ReplyDelete
  21. Mr.venkat you are realy super, excellent explanation in very easy manner to understand . your videos will become popular and you are the best asp.net trainer. Thank you a lot for your teaching & helping to the people. i would like to say i became fan of you .

    ReplyDelete
  22. what are use of web services,WPF,WCF and MVC?How?

    ReplyDelete
  23. Hi venkat,
    i have went thru you sql tutorial and asp.net tutorials as well...
    thanks for sharing the info along with small basics...

    Really grt work
    Thanks . you video helped me alot

    ReplyDelete
  24. Sir Really u done good job.. your video really help full for my type of beginners.

    I have one problem sir can u upload DataGridView control more example with all type of query like select,join, innerjoin result for C#.net desktop application. some time i want to display 2 join table in DataGridView query through is it possible.. ??

    ReplyDelete
    Replies
    1. Hi Nilesh, there are lot of videos on asp.net gridview tutorial that explains the concepts you mentioned. Here is the link
      http://www.youtube.com/user/kudvenkat/videos?view=1&flow=grid

      Tips to effectively use my youtube channel.
      http://www.youtube.com/watch?v=nT9uF09RMkw

      If you want to receive email alerts, when new videos are uploaded, please feel free to subscribe to my youtube channel.
      http://youtube.com/kudvenkat

      If you like these videos, please click on the THUMBS UP button below the video.

      May I ask you for a favour. I want these tutorials to be helpful for as many people as possible. Please free to share the link with your friends and family who you think would also benefit from them.

      Good Luck
      Venkat

      Delete
  25. Hi, I was asked in the interview. what are the advantages and disadvantages of Entity Framework? Also when using entity framework, it causes severe load on the server, then y did you chose entity framework? Can you please explain with real time example. Thanks.

    ReplyDelete
    Replies
    1. Advantages:

      One common syntax (LINQ) for all object queries whether it is database or not , Pretty fast if used as intended , easy to implement SoC , less coding required to accomplish complex tasks.

      Its fast and straight forward using LINQ/FE objects For Add/Modify/Delete/Update.

      Easy to map business objects (with drag & drop tables on environment). It keeps a good performance when you work with a small / middle domain model.

      Disadvantages:

      You have to think in a non-traditional way of handling data , not available for every database.

      If there is any schema change in database FE won’t work!!! You have to update the schema in solution as well!!!

      It's limited when you work with a huge domain model. -Scalability.

      Delete
  26. Hello Venkat,
    First of all thanks a lot for providing such a great material for .net,
    I am finding an issue ADO.net code in SQL server and ASP.net connectivity, getting an System.NullReferenceException with detail
    'Object reference not set to an instance of an object'. Kindly help me on this. Thank you

    ReplyDelete
  27. Hello Sir,
    Can u tell me the process for hosting asp.net website? what changes we have to make in 'web.config' file?

    ReplyDelete
  28. venkat is the best ex planer of .net very nice sir good job

    ReplyDelete
  29. When queries are taking time, check if the joins are correct. That is the tables involved in the joins must be joined on the key columns.If some joins are missing then the queries will be slow as it produces huge recordset. Also pay attention to the type of joins (inner join, left-right outer join,cross join) and choose the appropriate one as per your scenerio.
    Thanks

    ReplyDelete
  30. I have read all the comments posted above.your material is very good.

    I have not found anwers for this two Questions .Can you please help .
    Hi, I was asked in the interview. what are the advantages and disadvantages of Entity Framework? Also when using entity framework, it causes severe load on the server, then y did you chose entity framework? Can you please explain with real time example. Thanks.

    And Usually my users get a error in my website
    the state information is invalid for this page or might be corrupted.
    Can you please explain why this error and the solution to it ..pls reply

    ReplyDelete
  31. Mr.venkat you are realy super, excellent explanation in very easy manner to understand . your videos will become popular and you are the best asp.net trainer. Thank you a lot for your teaching & helping to the people. i would like to say i became fan of you .

    ReplyDelete
  32. Hello Sir,
    First off all I want thanks to you for your great work....keep on continue and help others...god bless you...
    I have some interview questions which I faced in some interview...
    1.What is binding in web services.
    2.How to access databases which is there in another machine to our database connected each other through lan(that machine is not a server machine).
    3.What is database mirroring....

    ReplyDelete
    Replies
    1. 1.Binding is where you connect your web service (what you are doing) to an endpoint location (where to execute it). A Web Services Definition Language (WSDL) binding looks like this.

      2.exec sp_addlinkedserver @server='IP'
      EXEC sp_addlinkedsrvlogin 'IP', 'false', NULL, 'sa', 'password'

      3.SQL Server database mirroring is a disaster recovery and high availability technique that involves two SQL Server instances on the same or different machines. One SQL Server instance acts as a primary instance called the principal, while the other is a mirrored instance called the mirror.

      Delete
  33. what is difference between page life cycle stages and life cycle events?

    ReplyDelete
  34. Really venkat sir, You are giving very nice information ..which i never get before.. Thanks a ton for that ..keep it up..

    ReplyDelete
  35. Awesome explanations .....thank u so much....I dint learn in class that much I learn by watching your video....thank so much sir....its vry help ful ....I shared ur video to my frnds n they are learning with out class.

    ReplyDelete
  36. Really venkat sir, You are giving very nice information ..which i never get before.. Thanks a ton for that
    sir i have one question why we need iis to restart or application pool when service unavailable problem occurs..
    why service unavailable problem occuring what setting to be impemented for that pls reply its very urgent

    ReplyDelete
  37. Really venkat sir, You are giving very nice information ..which i never get before.. Thanks a ton for that
    sir i want to ask one question in every 6hr or 5 hrs service unavailable problem occurs and we have to restart iis for that website or application pool recycle..what setting to be done to solved that issue

    ReplyDelete

If you are aware of any other asp.net questions asked in an interview, please post them below. If you find anything missing or wrong, please feel free to correct by submitting the form below.

 
Disclaimer - Terms of use - Contact Us