0
I have an AJAX method that sends me a certain value, when 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) {
}
});
Method C#
[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 the information coming via AJAX?
This question arises because opening two tabs where the same variable is used I cannot guarantee data integrity.