locked
How to improve performance RRS feed

  • Question

  • User1002530435 posted

    How to improve performance of a method which is taking long time or reasons of taking long time to execution of a method in C#?Please note we should not touch any backend like sql server.

    Friday, August 22, 2014 8:29 PM

Answers

  • User-1151753377 posted

    Hi ssramvinay.83,

    According to your description, you want to know how to How to improve performance in your web pages.

    please refer to these suggestions that i provided,  hope it can be helpful to you.

    • Disable Session State
      Disable Session State if you’re not going to use it.  By default it’s on. You can actually turn this off for specific pages, instead of for every page:
    <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="WebApplication1.WebForm1"
    EnableSessionState="false" %>
    

    You can also disable it across the application in the web.config by setting the <sessionState> mode value to Off.

    • Output Buffering
      Take advantage of this great feature.  Basically batch all of your work on the server, and then run a Response.Flush method to output the data.  This avoids chatty back and forth with the server.    <%response.buffer=true%>     Then use:   <%response.flush=true%>  

     

    • Always check Page.IsValid when using Validator Controls
      So you’ve dropped on some validator controls, and you think your good to go because ASP.net does everything for you!  Right? Wrong!  All that happens if bad data is received is the IsValid flag is set to false. So make sure you check Page.IsValid before processing your forms!

    • Page.IsPostBack is your friend
      Make sure you don’t execute code needlessly. I don’t know how many web developers forget about checking IsPostBack!  It seems like such a basic thing to me!  Needless processing!

    • Turn off Tracing
           Tracing is awesome, however have you remembered to turn it off? If not, make sure you edit your web.config and turn it off!  It will add a lot of overhead to your application that is not needed in a production environment.
    <configuration>
    <system.web>
    <trace enabled="false" pageOutput="false" />
    <trace enabled="false" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true"/>
    <compilation debug="false" />
    </system.web>
    </configuration>

    More information about how to improve the performance, please refer to the link below:

    http://www.realsoftwaredevelopment.com/20-tips-to-improve-aspnet-application-performance/

    if you have any other questions, please feel free to post in this forum.

    Best Regards,

    Summer

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, August 24, 2014 11:10 PM

All replies

  • User-434868552 posted

    @ ssramvinay.8...  welcome to forums.asp.net

    sorry, imho, your question is way too vague ... this may help you:  http://weblogs.asp.net/gerrylowry/clarity-is-important-both-in-question-and-in-answer.

    Quick answer:  one generally needs to look at the code closely.

    Friday, August 22, 2014 8:38 PM
  • User-1806150748 posted

    If it is DB oriented thing, please run that proc in SQL console, note the time, and if it is same as method call time, then you need to tweak that procedure, if it is not, i.e. no DB thing, then go for async, await pattern.

    Sunday, August 24, 2014 11:59 AM
  • User-1151753377 posted

    Hi ssramvinay.83,

    According to your description, you want to know how to How to improve performance in your web pages.

    please refer to these suggestions that i provided,  hope it can be helpful to you.

    • Disable Session State
      Disable Session State if you’re not going to use it.  By default it’s on. You can actually turn this off for specific pages, instead of for every page:
    <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="WebApplication1.WebForm1"
    EnableSessionState="false" %>
    

    You can also disable it across the application in the web.config by setting the <sessionState> mode value to Off.

    • Output Buffering
      Take advantage of this great feature.  Basically batch all of your work on the server, and then run a Response.Flush method to output the data.  This avoids chatty back and forth with the server.    <%response.buffer=true%>     Then use:   <%response.flush=true%>  

     

    • Always check Page.IsValid when using Validator Controls
      So you’ve dropped on some validator controls, and you think your good to go because ASP.net does everything for you!  Right? Wrong!  All that happens if bad data is received is the IsValid flag is set to false. So make sure you check Page.IsValid before processing your forms!

    • Page.IsPostBack is your friend
      Make sure you don’t execute code needlessly. I don’t know how many web developers forget about checking IsPostBack!  It seems like such a basic thing to me!  Needless processing!

    • Turn off Tracing
           Tracing is awesome, however have you remembered to turn it off? If not, make sure you edit your web.config and turn it off!  It will add a lot of overhead to your application that is not needed in a production environment.
    <configuration>
    <system.web>
    <trace enabled="false" pageOutput="false" />
    <trace enabled="false" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true"/>
    <compilation debug="false" />
    </system.web>
    </configuration>

    More information about how to improve the performance, please refer to the link below:

    http://www.realsoftwaredevelopment.com/20-tips-to-improve-aspnet-application-performance/

    if you have any other questions, please feel free to post in this forum.

    Best Regards,

    Summer

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, August 24, 2014 11:10 PM