简体   繁体   English

优化ASP.NET网站的性能

[英]Optimizing performance of an ASP.NET website

We are currently trying to optimize the performance of an ASP.NET based website which has been in development for quite a long time. 我们目前正在尝试优化基于ASP.NET的网站的性能,该网站已经开发了很长时间。 We are using MS Ajax with UpdatePanels and such. 我们正在将MS Ajax与UpdatePanels等配合使用。 ComponentArt is also part of the picture. ComponentArt也是图片的一部分。

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 . 最接近我们想要实现的线程是带有计时器page_load的c#updatepanel But we don't want to check the event target explicitly because there are dozens of them. 但是我们不想显式地检查事件目标,因为它们有数十种。

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. 抱歉,对服务器的每个请求(AJAX或其他请求)都会触发整个页面的生命周期-您需要找到一种确定是处理AJAX请求还是整个页面回发的好方法。

http://forums.asp.net/p/1089247/1629084.aspx#1629084 looks like it might help you, so for example you would want something like this: http://forums.asp.net/p/1089247/1629084.aspx#1629084看起来可能会对您有所帮助,例如,您需要这样的东西:

protected void Page_Load(object sender, EventArgs e)
{
    if(!ScriptManager.GetCurrent(this).IsInAsyncPostBack)
    {
        // This is a normal (i.e. full) postback
    }
}

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. 您可以使用IsPostBack属性来确定是第一次还是第二次页面加载。 Put all the logic you only want to run once in an if statement. 将所有只想运行一次的逻辑放在if语句中。

For example 例如

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

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
    }
}

Somehow I missed responding to the replies here. 我莫名其妙地错过了回复这里的答复。 Thanks a lot for the input guys! 非常感谢你们的投入!

"IsInAsyncPostBack" is what I needed. 我需要“ IsInAsyncPostBack”。 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. 提交了我的建议以删除现有的前端代码库并切换到Silverlight或Flex。

Thanks again and sorry for the delay in replying. 再次感谢您,我们不便答复。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM