I wrote this WebService in C#:
public class Service : IService
{
TestClass testObject = new TestClass();
public string GetData()
{
testObject.Counter++;
return string.Format("Test Value: {0}", testObject.Counter);
}
}
public class TestClass
{
public int Counter { get; set; }
public TestClass()
{
Counter = 0;
}
}
It's a WebService and each time I invoke my WebService it recreates everthing. So my counter never increase and each time I invoke GetData()
the WebService return "1".
What are the solutions to persist my data between each WebService invoke.
- Database, I would like to avoid this solution,
- State on the client, How ?
- session, Is there an easy way to use this?
- persistent service. Is this working?
Do you know articles than explain how to persist data with WebService?
Thank you,