1. 在.aspx中添加异步标记

<%@ Page Language="C#" Async="true"%>

2. 在.aspx.cs或者.ascx.cs(用户控件)中添加异步方法

private async Task GetMyPosts()
{
    var posts = await ServiceFactory.BlogPostSevice.GetBlogPostsPagedAsync();
    rpPosts.DataSource = posts;
    rpPosts.DataBind();
}

3. 在.aspx.cs或者.ascx.cs的Page_Load或者OnLoad注册异步方法

protected void Page_Load(object sender, EventArgs e)
{
    this.Page.RegisterAsyncTask(new PageAsyncTask(GetMyPosts));
}

搞定! 

【参考资料】

How to create Asynchronous device Page in ASP.NET 4.5

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-23
  • 2021-07-10
  • 2021-05-29
  • 2022-12-23
  • 2021-10-11
  • 2022-01-01
猜你喜欢
  • 2022-12-23
  • 2021-08-10
  • 2021-06-02
  • 2021-10-03
  • 2021-06-28
  • 2021-12-10
  • 2021-12-05
相关资源
相似解决方案