session state ???

Discussion in 'ASP .Net Web Services' started by cmrchs@yahoo.com, Sep 29, 2004.

  1. Guest

    Hi,

    I have following function in a WebService-class :

    [WebMethod(EnableSession=true)]
    public int Count()
    {
    if ( null == Session["mycounter"] )
    Session["mycounter"] = 0;
    else
    m_counter = (int)Session["mycounter"];
    Session["mycounter"] = ++m_counter;
    return m_counter;
    }
    'm_counter' is a datamember of the class.

    When calling the WS-function from IExplorer several times do I get an incremented count as return value : OK

    .... but invoking the same WS-function from a ConsoleApp always returns me the same value of 1 ???

    result = calc.Count();
    result = calc.Count();
    Console.WriteLine("Count : {0}", result);

    how come ?
    thnx
    Chris

    **********************************************************************
    Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
    Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
    , Sep 29, 2004
    #1
    1. Advertising

  2. BrunoX Guest

    Use a CookieContainer:

    System.Net.CookieContainer cookieContainer1 = new
    System.Net.CookieContainer();
    MyWebService.Calc calc = new MyWebService.Calc();
    calc.CookieContainer = cookieContainer1;
    result = calc.Count();
    result = calc.Count();
    Console.WriteLine("Count : {0}", result);

    "Chris C" wrote:

    > Hi,
    >
    > I have following function in a WebService-class :
    >
    > [WebMethod(EnableSession=true)]
    > public int Count()
    > {
    > if ( null == Session["mycounter"] )
    > Session["mycounter"] = 0;
    > else
    > m_counter = (int)Session["mycounter"];
    > Session["mycounter"] = ++m_counter;
    > return m_counter;
    > }
    > 'm_counter' is a datamember of the class.
    >
    > When calling the WS-function from IExplorer several times do I get an incremented count as return value : OK
    >
    > .... but invoking the same WS-function from a ConsoleApp always returns me the same value of 1 ???
    >
    > result = calc.Count();
    > result = calc.Count();
    > Console.WriteLine("Count : {0}", result);
    >
    > how come ?
    > thnx
    > Chris
    >
    > **********************************************************************
    > Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
    > Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
    >
    BrunoX, Nov 8, 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. shamanthakamani
    Replies:
    1
    Views:
    3,473
    Natty Gur
    Nov 20, 2003
  2. Not Liking Dot Net Today
    Replies:
    0
    Views:
    593
    Not Liking Dot Net Today
    Apr 21, 2004
  3. Maciek
    Replies:
    0
    Views:
    8,227
    Maciek
    Sep 15, 2005
  4. jnickfl1
    Replies:
    0
    Views:
    572
    jnickfl1
    Sep 18, 2006
  5. Harry Haller
    Replies:
    0
    Views:
    1,640
    Harry Haller
    Nov 7, 2006
Loading...

Share This Page