Breaking changes in .net 4.5 Callcontext when executing HTTP post in ashx?

I just installed .Net 4.5 and noticed that an existing web application still running under .Net 4 fails when I try to retrieve an element from the CallContext, when it worked fine before installing and has done in the last year.

In the AuthenticateRequest event of the application, we use the user's Identity to load additional information about the user's security. This is then added to the CallContext for later use.

eg.

 protected void Application_AuthenticateRequest(object sender, EventArgs e)
    {
        if (HttpContext.Current.User != null && HttpContext.Current.User.Identity.IsAuthenticated)
        { 
             // set someValue 
            CallContext.SetData(ContextIdentifier, someValue);
        }
    }

      

The value in the callcontext is retrieved at subsequent points in the lifecycle. for example CallContext.GetData (ContextIdentifier)

However, when requesting .ashx from a http "POST" request, the value is now null, but on a "GET" request, this value is correct.

I can't find a documented reason why this suddenly changed or is it now by design and why would it affect existing .Net 4 applications?

My obvious solution is to put the data in the HTTPContext as well, but without understanding the reasons why I am not sure that using CallContext will cause problems elsewhere!

Any help / understanding would be greatly appreciated

+2


source to share


1 answer


http://forum.springframework.net/showthread.php?572-CallContext-vs-ThreadStatic-vs-HttpContext



It looks like it was an http pipeline containing the calling context, but I only have to see it because of the improvements

+1


source







All Articles