session state ???

  • Thread starter Thread starter cmrchs
  • Start date Start date
C

cmrchs

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...
 
Are you managing the cookie in your console app? You must send the cookie
up - otherwise, ASP.NET will have no way to provide session management.
State management is usually not a good idea for web services, as most
clients have no idea that they need to push a cookie.


--
Mickey Williams
Author, "Visual C# .NET Core Ref", MS Press
www.neudesic.com
www.servergeek.com


Chris C said:
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...
 
Hi Chris,

Try to instantiate CookieContainer class for CookieContainer property of
your using proxy object.

Chris C said:
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...
 
Back
Top