c# - How to access a global variable from a WebMethod? -
i have following global variable:
private arraylist listselectedunavailables { { return (arraylist)viewstate["listselectedunavailables"]; } set { viewstate["listselectedunavailables"] = value; } }
i can work in every single procedure of webform.
however, need use in webmethod have in same webform, seems not identify of global variables. so:
how can access global variable webmethod?
a viewstate
property depends on having page (.aspx) post view state, that's "variable" stored. webmethod
not include full page postback (if post @ all) , there no view state read from. instead may want use session variable like:
private arraylist listselectedunavailables { { return (arraylist)session["listselectedunavailables"]; } set { session["listselectedunavailables"] = value; } }
the session stores variable in web server's memory (but related specific browser session). has it's own draw-backs, such being volatile worker process reset, load balancing cosiderations, etc.
Comments
Post a Comment