Now I have done some research. I need to save some data that I received from ajax call to my WebMethod on my page, to some place where I can return it back at any time.
At first I thought that ViewState would be a better option. Unfortunately, you cannot refer to it in the same way as to non-static methods. Even if I create an instance of the page to be stored in the ViewState, I believe that at the end of the method, all the data that will be destroyed will be destroyed.
I need this data for the purposes of database calls that I execute in other WebMethods.
The main method in my C # codebehind for my aspx page is as follows:
[WebMethod] [ScriptMethod] public static string populateModels(string[] makeIds) { }
So, for example, I need to save the selected commands in order to pull them out for future database queries. Since most of my mailboxes are cascaded in terms of filtering and pulling from the database.
Update:
This code works to retrieve and store data in a SessionState in static WebMethods.
[WebMethod(EnableSession = true)] [ScriptMethod] public static string populateYears(string[] modelIds) { HttpContext.Current.Session["SelectedModels"] = modelIds; string[] makeids = (string[])HttpContext.Current.Session["SelectedMakes"]; }
source share