asp.net定时器载入页面内容
问题描述:
asp.net
C#
asp.net定时器载入页面内容
我们的网页目前包含了一个相当大的web应用程序导致attemping导航到它时,一个长的延迟。我目前正在实施一个WCF Web服务来利用Ajax,但延迟是我的雇主关心的问题,所以他想在此期间进行一个快速和肮脏的修复。
我想有空的页面加载,然后使用计时器加载内容。这将减少感知页面加载时间,但我不确定如何完成它。
任何帮助,将不胜感激
肖恩
答
一些代码来让你开始:
在asp.net页面:
<asp:Timer ID="Timer1" OnTick="Timer1_Tick" runat="server" Interval="1">
</asp:Timer>
<asp:UpdatePanel ID="updatePanel1" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
<ContentTemplate>
.... your stuff here
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress1" runat="server" DisplayAfter="100">
<ProgressTemplate>
Please wait...
</ProgressTemplate>
</asp:UpdateProgress>
在后面的代码:
protected void Timer1_Tick(object sender, EventArgs e)
{
this.Timer1.Enabled = false;
StartLongRunningTask();
}
答
而不是一个计时器,你可以用Response.Flush()
冲洗Response
。
你有没有考虑其他技术,如使用gzip压缩的响应,使用JS最小化等? – RichardOD 2009-12-02 13:07:52