In my code I'm using static field for storing a particular value.
public static int webServiceId;
I have remove that and use any other solution. But the value should retain after postback. We can't use Session or ViewState here. Coz I'm working with services (in Service layer).
Example:
I get webservice id in the below method of xyz.cs file:
public int SetWebServiceInformation(int? webServiceID, string webServiceName)
{
context.WebService_InsertUpdate(ref webServiceID, webServiceName);
webServiceId = webServiceID.Value;
return webServiceID.Value;
}
and then controls goes to another method of different class file (say abd.cs file).And suppose in calling method exception comes it will call method LogError(Exception error) of my first class file (xyz.cs). And when the control comes back in our class file (xyz.cs) we need the webservice Id back. Coz we are using that to store exception info into the database according to the webservice Id.
protected void LogError(Exception error)
{
----//some logic to get errorLogID//---
if (errorLogID > 0)
WebServiceErrorLogging(errorLogID, webServiceId);
//here we have webServiceId is a static variable
}