I'm trying to create an asynchronous task in ASP.NET Webforms. After studying the various sources from the Internet, I created this:
Default.aspx:
namespace AsyncTestCs
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
RegisterAsyncTask(new PageAsyncTask(LoadSomeData));
}
public async Task LoadSomeData()
{
var downloadedString = await new WebClient().DownloadStringTaskAsync("http://localhost:59850/WebForm1.aspx");
Label1.Text = downloadedString;
}
}
}
WebForm1.aspx:
namespace AsyncTestCs
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Thread.Sleep(5000);
Response.Write("something");
}
}
}
but it does not work asynchronously. This page will be displayed after it loads downloadedString.
Where is my mistake?