Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7631901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:28:38+00:00 2026-05-31T06:28:38+00:00

There is a new app setting in asp.net 4.5 <add key=aspnet:UseTaskFriendlySynchronizationContext value=true /> code

  • 0

There is a new app setting in asp.net 4.5

<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />

code like this can run in asp.net 4.0

protected void Button1_Click(object sender, EventArgs e)
{
    CallAysnc();
}

public void CallAysnc()
{
    AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(Guid.NewGuid().ToString());

    WebClient client = new WebClient();
    client.DownloadStringCompleted += (object sender, DownloadStringCompletedEventArgs e) =>
    {
        asyncOp.PostOperationCompleted(CallCompleted, e.Result);
    };
    client.DownloadStringAsync(new Uri("http://www.google.com"));
}

private void CallCompleted(object args)
{
    Response.Write(args.ToString());
}

But it doesn’t work in asp.net 4.5,and when I remove the new appsetting,it works again!

So what’s the meaning of “UseTaskFriendlySynchronizationContext” ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T06:28:39+00:00Added an answer on May 31, 2026 at 6:28 am

    Regarding UseTaskFriendlySynchronizationContext, from Microsoft Forums:

    That tells ASP.NET to use an entirely new asynchronous pipeline which
    follows CLR conventions for kicking off asynchronous operations,
    including returning threads to the ThreadPool when necessary. ASP.NET
    4.0 and below followed its own conventions which went against CLR guidelines, and if the switch is not enabled it is
    very easy for asynchronous methods to run synchronously, deadlock the request, or otherwise not behave as expected.

    Also, I think AsyncOperationManager is intended for desktop applications. For ASP.NET apps you should be using RegisterAsyncTask and setting <%@ Page Async="true", see here for more details.

    So using the new c# keywords your example would be:

    protected void Button1_Click(object sender, EventArgs e)
    {
        RegisterAsyncTask(new PageAsyncTask(CallAysnc));
    }
    
    private async Task CallAysnc()
    {
        var res = await new WebClient().DownloadStringTaskAsync("http://www.google.com");
        Response.Write(res);
    }
    

    The aim is to support the following by release but is not currently supported in the beta:

    protected async void Button1_Click(object sender, EventArgs e)
    {
        var res = await new WebClient().DownloadStringTaskAsync("http://www.google.com");
        Response.Write(res);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're creating a new consumer/public-facing ASP.Net web app. There are two concerns: --Use cookie
I'm new to Linux but have to port a asp.net app to Linux platform.
I am having an issue in my Asp.net app where I am setting the
Merging the web.config files of a legacy ASP.NET App and a new MVC app
Is there a way to run New Relic Server Monitor with Google App Engine
I know this is the list of permissions in android Is there any new
I am developing an ASP.NET MVC app with custom membership and role providers. My
I'm trying to deploy my new ASP.NET MVC 2.0 website to our Windows Server
Is there a way to access the file-system outside of the current ASP.NET application,
In my web app (ASP.NET MVC), I send an email using the following: MailMessage

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.