0

We are currently trying to optimize the performance of an ASP.NET based website which has been in development for quite a long time. We are using MS Ajax with UpdatePanels and such. ComponentArt is also part of the picture.

The page load method is very heavy and we are trying to trim some fat from here. Is there any way we can avoid calling page load during a partial postback by a control within an update panel. Is this possible at all without hampering other functionality on the page?

The thread closest to what we are trying to achieve is c# updatepanel with timer page_load. But we don't want to check the event target explicitly because there are dozens of them.

4 Answers 4

1

Sorry, every request to the server (AJAX or otherwise) triggers the full page lifecycle - you need to find a good way of determining if you are dealing with an AJAX request or a full page postback.

http://forums.asp.net/p/1089247/1629084.aspx#1629084 looks like it might help you, so for example you would want something like this:

protected void Page_Load(object sender, EventArgs e)
{
    if(!ScriptManager.GetCurrent(this).IsInAsyncPostBack)
    {
        // This is a normal (i.e. full) postback
    }
}
Sign up to request clarification or add additional context in comments.

Comments

0

The page load method is called with every post back including the first time the page is loaded.

You can use the IsPostBack property to determine if it is the first time page loading or the second time. Put all the logic you only want to run once in an if statement.

For example

if (!IsPostBack)
{
   // Do stuff on the first page load only
}

Comments

0

You can check if partial rendering is being requested by using

void Page_Load(object sender, EventArgs e)
{
    if (!ScriptManager.GetCurrent(this).IsInAsyncPostBack)
    {
        // Do stuff only needed for full rendering here
    }
}

Comments

0

Somehow I missed responding to the replies here. Thanks a lot for the input guys!

"IsInAsyncPostBack" is what I needed. But after analyzing the project thoroughly, I concluded that it was too convoluted to be optimized in this fashion since it was not originally designed to function that way. Have submitted my proposal to chuck the existing frontend codebase and switch to either Silverlight or Flex.

Thanks again and sorry for the delay in replying.

2 Comments

This isn't a forum - there is no pressure to reply, but its always nice to hear how things worked out in the end! :-)
@Justin: My proposal to switch to Silverlight was not accepted at the time and we ended up using the ANTS Performance Profiler from Red Gate which worked very well. But even after implementing the performance tuneups, the site was still taking a decade to load. Ultimately, the higher powers decided to go with Silverlight. I was still around to see that happen :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.