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

node.js - How to mock a third-party api calls in the backend -

node.js - Why do I get "SOCKS connection failed. Connection not allowed by ruleset" for some .onion sites? -

matlab - 0-by-1 sym - What do I need to change in order to get proper symbolic results? -