.NET Framework - WebMethod asynchronous

Asked By Hollow Quincy on 08-Mar-11 06:21 PM
Hi, I have webmethod in code behind:

[System.Web.Services.WebMethod]
public static string f(string arg)   { return "a"; }

In aspx I have:
CodeBehind="Default.aspx.cs" Inherits="Dad._Default" Async='true'%>
EnablePageMethods="true"  />
PageMethods.f('arg',CallSuccess, CallFailed);

Is it asynchronous call of this webmethod or is it synchronous ?
I cannot find the answer..  I suspect, that it is synchronous because
my firefox does not respond for a while..

Thank you for help




Jason Keats replied to Hollow Quincy on 09-Mar-11 07:25 AM
I am a little confused, as I would only expect to see the WebMethod
attribute on a web service - not on a method within an ASP.NET website
(which is implied by your use of the term "code behind").

Calls to (code behind) methods within an ASP.NET website are
synchronous. Calls to methods in a web service may by synchronous or
asynchronous - depending on how they are coded.
Hollow Quincy replied to Jason Keats on 09-Mar-11 07:57 AM
%>

So I am using synchronous calls..
PageMethods.f('arg',CallSuccess, CallFailed);
So how can I do it asynchronous ?
Jason Keats replied to Hollow Quincy on 09-Mar-11 08:21 AM
Sorry, I got it slightly wrong in my previous statement. I should have
said that calls to (code behind) methods within your ASP.NET site are
synchronous if you are using a normal postback approach - however, it
looks like you are wanting to use JavaScript.

I am still uncertain whether you want to use JavaScript to
(asynchronously) call a method within your own site, or one within a
separate webservice. Are you using jQuery or something else?