You'll need to use a client-side timer (or some other method) to have the browser ask the server for the update, such as this simplified example:
<asp:UpdatePanel ID="up" runat="server">
<ContentTemplate>
<asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="timer_Ticked" />
<asp:Label ID="Label1" runat="server" Text="1" />
</ContentTemplate>
</asp:UpdatePanel>
Then in your codebehind:
protected void timer_Ticked(object sender, EventArgs e)
{
Label1.Text = (int.Parse(Label1.Text) + 1).ToString();
}
If you have a background process that is updating some state, you will either need to store the shared state in the session, http cache, or a database. Note that the cache can expire due to many factors, and background threads can be killed any any tie if IIS recycles the application pool.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…