WebMethod asynchronous

  • Thread starter Thread starter Hollow Quincy
  • Start date Start date
H

Hollow Quincy

Hi, I have webmethod in code behind:

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

In aspx I have:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="Dad._Default" Async='true'%>
<asp:ScriptManager ID="ScriptManager1" runat="server"
EnablePageMethods="true" />
<script type="text/javascript">
PageMethods.f('arg',CallSuccess, CallFailed);

Is it asynchronous call of this webmethod or is it synchronous ?
I can't find the answer.. I suspect, that it is synchronous because
my firefox doesn't respond for a while..

Thank you for help
 
Hollow said:
Hi, I have webmethod in code behind:

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

In aspx I have:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="Dad._Default" Async='true'%>
<asp:ScriptManager ID="ScriptManager1" runat="server"
EnablePageMethods="true" />
<script type="text/javascript">
PageMethods.f('arg',CallSuccess, CallFailed);

Is it asynchronous call of this webmethod or is it synchronous ?
I can't find the answer.. I suspect, that it is synchronous because
my firefox doesn't respond for a while..

Thank you for help


I'm 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're coded.
 
Hollow said:
Hi, I have webmethod in code behind:
[System.Web.Services.WebMethod]
public static string f(string arg)   { return "a"; }
In aspx I have:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="Dad._Default" Async='true'%>
<asp:ScriptManager ID="ScriptManager1" runat="server"
EnablePageMethods="true"  />
<script type="text/javascript">
PageMethods.f('arg',CallSuccess, CallFailed);
Is it asynchronous call of this webmethod or is it synchronous ?
I can't find the answer..  I suspect, that it is synchronous because
my firefox doesn't respond for a while..
Thank you for help

I'm 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're coded.

So I am using synchronous calls..
<script type="text/javascript">
PageMethods.f('arg',CallSuccess, CallFailed);
So how can I do it asynchronous ?
 
Hollow said:
Hollow said:
Hi, I have webmethod in code behind:
[System.Web.Services.WebMethod]
public static string f(string arg) { return "a"; }
In aspx I have:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="Dad._Default" Async='true'%>
<asp:ScriptManager ID="ScriptManager1" runat="server"
EnablePageMethods="true" />
<script type="text/javascript">
PageMethods.f('arg',CallSuccess, CallFailed);
Is it asynchronous call of this webmethod or is it synchronous ?
I can't find the answer.. I suspect, that it is synchronous because
my firefox doesn't respond for a while..
Thank you for help

I'm 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're coded.

So I am using synchronous calls..
<script type="text/javascript">
PageMethods.f('arg',CallSuccess, CallFailed);
So how can I do it asynchronous ?

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're using a normal postback approach - however, it
looks like you're wanting to use JavaScript.

I'm 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?
 
Back
Top