Static/Shared Webmethod

Discussion in 'ASP .Net' started by Rory Becker, Jun 12, 2008.

  1. Rory Becker

    Rory Becker Guest

    I have been testing a beta feature in Coderush (CodeIssues) which has prompted
    me with the suggestion that one of my WebMethods in a Webservice, could be
    Shared/Static and is not.

    I have never though about this before but I guess I had assumed that there
    is very little point in declaring such a method static or not as the web
    is stateless ( isn't it?)

    Is Coderush correct to suggest this or should I be filing a bug?

    --
    Rory
     
    Rory Becker, Jun 12, 2008
    #1
    1. Advertising

  2. Rory Becker

    bruce barker Guest

    if a class method does not reference any its instance members, then it can be
    declared static (class method rather than instance method).

    class methods are marginally faster (one less parameter, the class instance)
    and can be called without creating a class instance.

    -- bruce (sqlwork.com)


    "Rory Becker" wrote:

    > I have been testing a beta feature in Coderush (CodeIssues) which has prompted
    > me with the suggestion that one of my WebMethods in a Webservice, could be
    > Shared/Static and is not.
    >
    > I have never though about this before but I guess I had assumed that there
    > is very little point in declaring such a method static or not as the web
    > is stateless ( isn't it?)
    >
    > Is Coderush correct to suggest this or should I be filing a bug?
    >
    > --
    > Rory
    >
    >
    >
     
    bruce barker, Jun 12, 2008
    #2
    1. Advertising

  3. Hi Rory,

    I think Bruce's explanation is reasonable. However, for ASP.NET webservice,
    webmethod does should be defined as instance method rather than static. I
    think the Coderush might just treat webservice class as as a normal
    class(doesn't have sense of webservice). Anyway, I think you you can
    report this behavior since in webservice context, that message does be a
    bit misleading.

    Sincerely,

    Steven Cheng
    Microsoft MSDN Online Support Lead


    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:
    .

    ==================================================
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    ications.

    ==================================================
    This posting is provided "AS IS" with no warranties, and confers no rights.

    --------------------
    >Date: Thu, 12 Jun 2008 13:59:30 +0000 (UTC)
    >Message-ID: <>
    >From: Rory Becker <>
    >Subject: Static/Shared Webmethod


    >
    >I have been testing a beta feature in Coderush (CodeIssues) which has

    prompted
    >me with the suggestion that one of my WebMethods in a Webservice, could be
    >Shared/Static and is not.
    >
    >I have never though about this before but I guess I had assumed that there
    >is very little point in declaring such a method static or not as the web
    >is stateless ( isn't it?)
    >
    >Is Coderush correct to suggest this or should I be filing a bug?
    >
    >--
    >Rory


    >
    >
     
    Steven Cheng [MSFT], Jun 13, 2008
    #3
    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. DJ Dev
    Replies:
    3
    Views:
    16,240
    Gandalf
    Feb 8, 2004
  2. Joe Fallon
    Replies:
    3
    Views:
    788
    =?Utf-8?B?Z3V5?=
    Jul 16, 2004
  3. ben
    Replies:
    3
    Views:
    532
    Kevin Spencer
    Nov 15, 2004
  4. tshad
    Replies:
    11
    Views:
    848
    tshad
    May 27, 2005
  5. tropos
    Replies:
    3
    Views:
    483
Loading...

Share This Page