WebMethod asynchronous

Discussion in 'ASP .Net' started by Hollow Quincy, Mar 8, 2011.

  1. 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 Quincy, Mar 8, 2011
    #1
    1. Advertising

  2. Hollow Quincy

    Jason Keats Guest

    Hollow Quincy wrote:
    > 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.
     
    Jason Keats, Mar 9, 2011
    #2
    1. Advertising

  3. On 9 Mar, 13:25, Jason Keats <> wrote:
    > Hollow Quincy wrote:
    > > 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 Quincy, Mar 9, 2011
    #3
  4. Hollow Quincy

    Jason Keats Guest

    Hollow Quincy wrote:
    > On 9 Mar, 13:25, Jason Keats<> wrote:
    >> Hollow Quincy wrote:
    >>> 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?
     
    Jason Keats, Mar 9, 2011
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Temp
    Replies:
    1
    Views:
    1,099
    Natty Gur
    Aug 11, 2003
  2. sunnyz
    Replies:
    1
    Views:
    2,960
    Kevin Spencer
    Oct 15, 2004
  3. Kevin Spencer

    Strange Exception with WebMethod

    Kevin Spencer, Oct 25, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    426
    Kevin Spencer
    Oct 28, 2004
  4. Franck
    Replies:
    1
    Views:
    485
    Karl Seguin
    Oct 4, 2005
  5. Ram P. Dash
    Replies:
    0
    Views:
    530
    Ram P. Dash
    Nov 18, 2005
Loading...

Share This Page