I need to make an Ajax call to my Azure B2C Tenant to obtain the token. When run normally using Eval it completes correctly by calling a WebMethod which parses the token. I’m only in need of the email address in the token for authentication. I need the script to complete and obtain the email address prior to further authentication inside my vb.net web app. Running the method as a task using EvalAsync the javascript hangs and never returns the task. Would you look at my code to see what I’m doing wrong?
Hi Gerald,
The issue is that the task never exists the “WaitingForActivation” state, meaning it hangs trying to finish the task (it gets stuck in the Task queue).
Now the status is not the issue in itself, but rather an indication of why your application hangs.
And that’s because “task.Wait()” is called further up the stack, and that’s what’s causing the deadlock.
What you can do is either.
I attached a modified version of the test case you provided, in it, you’ll see 3 new Methods – ProcessDataAsync1, ProcessDataAsync2, and ProcessDataAsync3. Each one represents the different approaches you can use to deal with Asynchronous calls.
Promise-style Tasks should always have a timeout, otherwise, the whole application can hang on a single call, that’s why your script works when you use Application.Eval() and hangs with Application.EvalAsync().
HTH,
Alaa
Thanks Alaa!
I used the third suggested method. I still had some issues trying to obtain the token (email) before the remainder of the internal authentication commenced. Ultimately, I simply placed the method call for the internal authentication in the Web Method. That meant the desired email address was obtained prior to internal authentication.
FYI, in the javascript code you updated you added the elements req.setCrossDomain(true); and req.setProhibitCaching(false);. Initially, the web method would not fire. On a lark, I commented out these items and it began to work. I’m not sure what the issue was but I thought I’d give you the feedback. It works fine now.
Thanks again!
Gerry
Please login first to submit.