Sessions with web services

Discussion in 'ASP .Net Web Services' started by Joshua Ellul, Feb 16, 2004.

  1. Joshua Ellul

    Joshua Ellul Guest

    Hi There,

    Could someone tell me how to implement sessions in web services?

    I am using the EnableSession property (set to true)... however, the session
    is not being maintained... is there something I am missing? Perhaps setting
    a session time out? The client of the web service is an asp.net web form.

    Thanks,

    Josh
    Joshua Ellul, Feb 16, 2004
    #1
    1. Advertising

  2. Joshua Ellul

    Jan Tielens Guest

    To maintain session state:

    WebMethodAttribute.EnableSession Property
    Indicates whether session state is enabled for an XML Web service method.
    http://tinyurl.com/2rs6d

    Did you follow following example (see url also)?
    <%@ WebService Language="C#" Class="Util" %>

    using System.Web.Services;

    public class Util: WebService {
    [ WebMethod(Description="Per session Hit Counter",EnableSession=true)]
    public int SessionHitCounter() {
    if (Session["HitCounter"] == null) {
    Session["HitCounter"] = 1;
    }
    else {
    Session["HitCounter"] = ((int) Session["HitCounter"]) + 1;
    }
    return ((int) Session["HitCounter"]);
    }
    }


    --
    Greetz

    Jan Tielens
    ________________________________
    Read my weblog: http://weblogs.asp.net/jan


    "Joshua Ellul" <> wrote in message
    news:...
    > Hi There,
    >
    > Could someone tell me how to implement sessions in web services?
    >
    > I am using the EnableSession property (set to true)... however, the

    session
    > is not being maintained... is there something I am missing? Perhaps

    setting
    > a session time out? The client of the web service is an asp.net web form.
    >
    > Thanks,
    >
    > Josh
    >
    >
    Jan Tielens, Feb 16, 2004
    #2
    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. Ken Cox [Microsoft MVP]

    Re: Relationship between IIS Sessions and ASP.NET Sessions?

    Ken Cox [Microsoft MVP], Aug 8, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    5,358
    Luther Miller
    Aug 8, 2003
  2. Nick
    Replies:
    1
    Views:
    6,120
    Alvin Bruney - ASP.NET MVP
    Sep 12, 2005
  3. scottymo
    Replies:
    3
    Views:
    693
    Dominick Baier
    Sep 30, 2006
  4. John
    Replies:
    4
    Views:
    441
  5. Bookham Measures

    Moving from ASP Sessions to Database Sessions

    Bookham Measures, Jul 23, 2007, in forum: ASP General
    Replies:
    19
    Views:
    560
    Bookham Measures
    Aug 23, 2007
Loading...

Share This Page