I have a method in AJAX that sends me a certain value, when so requested, for a session variable (a list of strings in this case).
Session Variable
private static List<string> ListData {
get{return (List<string>) Session["ListDataSession"];}
set {Session["ListDataSession"]=value;}
}
AJAX Method
$.ajax({
type: "POST",
url: "Teste.aspx/UpdateData",
data: '{name: "' + "newValue"+ '" }',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function(response) {
}
});
C # method
[System.Web.Services.WebMethod]
public static bool UpdateData(string name)
{
UpdateData.Add(name);
return true;
}
How to make this single session variable in this type of cases where I need to have declared a static variable to manage information coming via AJAX?
This issue arises because opening two tabs where the same variable is used can not guarantee the integrity of the data.