I have a list of objects in an asp.net page. Each object represents a product of a shop, consisting of the name of the product, product id, price, available quantity etc. A customer can select a product from a drop down list, and the corresponding fields, such as price, quantity etc are automatically filled with the appropriate values. For performance reason, when the page loads I have fetched the whole list of products from the database and stored it inside the "Cache['Product']" variable, so that when the value change event of the drop down occurs, I can get the corresponding values without any database queries.
This strategy works fine in my local development environment, but when the page is uploaded to the server, the corresponding fields are not getting appropriate values. Even when a product is selected from the drop down, the corresponding fields are not showing the appropriate price, quantity etc. Seems like my caching strategy is not working.
I don't know what is wrong here. I have set the cache variable as follows :
if(Cache["ProductList"] == null)
Cache.Insert("ProductList", Product, null, DateTime.Now.AddHours(1), Cache.NoSlidingExpiration);
When I need to retrieve the cache values, I have done it like below :
List<Product> CachedProduct = (List<Product> )Cache["ProductList"];
I have absolutely no idea what could be the problem here. I need some help :(