I am coding this ASMX web service and I want to use a class variable to manage the response message I send back. I just want to make sure that if multiple client call a web service at the same time the private variable will not be shared amongst the clients creating erratic behaviors. Here is the sample code:
NOTE the variable message is used in all web services of this class I just put one simple method for the sake of presentation.
private string message;
[WebMethod]
public DomainResponseMultiple FindAll(string user, string password, EntityEnum entity)
{
DomainResponseMultiple response;
if (Authenticate(user, password, out message) && HasReadPrivileges(user, out message))
{
SelectAllTransaction transaction = new SelectAllTransaction(user, entity);
response = (DomainResponseMultiple)transaction.Execute();
}
else
{
response = new DomainResponseMultiple();
response.ResponseCode = ResponseCode.Error;
response.Message = message;
}
return response;
}
This variable will be available on the Session scope, as per user, persistant to his session, until it times out according to your configuration