c# - Global class variable for ASP.NET -


i building asp.net application has 2 projects. 1 class library having bl code. want create public class instance variable 1 of classes in bl. class instance variable avoid loading data on each request makes application respond slow each request. how make global class variable load data @ page_load, , keep until user redirects page.

create in viewstate , wrap in property easy of use. along lines of:

public myclass myobj {     {         if (viewstate["myobj"] == null){              viewstate["myobj"] = new myclass();         }         return viewstate["myobj"];      }     set {         viewstate["myobj"] = value;     } } 

Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -