protected void uploadProfilePhotoButton_Click(object sender, EventArgs e) { this.RegisterAsyncTask( new PageAsyncTask( async ct => { if (this.profilePhoto.PostedFile.ContentType == null) { this.photoUploadedLabel.Visible = true; this.photoUploadedLabel.Text = "Select a file first."; return; } var twitter = new TwitterConsumer(); XDocument imageResult = await twitter.UpdateProfileImageAsync( this.AccessToken, this.profilePhoto.PostedFile.InputStream, this.profilePhoto.PostedFile.ContentType); this.photoUploadedLabel.Visible = true; })); }