i wanna add some data into cache so, i used below code. its working perfectly from development computer when i publish into server then its throwing exception "Object reference not set to an instance of an object. Inner Exception is ", using log i found
the place of issue, its at exactly if (cache["Key1"] == null)
System.Web.Caching.Cache cache = new System.Web.Caching.Cache();
the reason why im using System.Web.Caching.Cache is, i have another vb.net project, its like Public Shared Function GetContentString(ByRef cache As Cache) there its expecting object of System.Web.Caching.Cache
really i dont know the reason of why its not working only from server? do i need to change anything in IIS? experts can you please help me!!
its throwing exception "Object reference not set to an instance of an object.
I suspect that in elsewhere you get cache["Key1"] with null and convert it to other type or assign it to another variable etc, which might cause the issue.
Besides, if you'd like to share data between multiple applications built with different languages (or platform), you can use Redis Cache etc. Or store the data in a temporary table in your database.
With Regards,
Fei Han
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Member
297 Points
1356 Posts
unable to use System.Web.Caching.Cache in server
Oct 10, 2018 10:02 AM|winseealn@hotmail.com|LINK
hello all,
i wanna add some data into cache so, i used below code. its working perfectly from development computer when i publish into server then its throwing exception "Object reference not set to an instance of an object. Inner Exception is ", using log i found the place of issue, its at exactly if (cache["Key1"] == null)
System.Web.Caching.Cache cache = new System.Web.Caching.Cache();
if (cache["Key1"] == null)
{
cache.Add("Key1", "Value 1", null, DateTime.Now.AddSeconds(60), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, null);
}
the reason why im using System.Web.Caching.Cache is, i have another vb.net project, its like Public Shared Function GetContentString(ByRef cache As Cache) there its expecting object of System.Web.Caching.Cache
really i dont know the reason of why its not working only from server? do i need to change anything in IIS? experts can you please help me!!
Thank you
All-Star
53001 Points
23592 Posts
Re: unable to use System.Web.Caching.Cache in server
Oct 10, 2018 11:31 AM|mgebhard|LINK
This could be a design bug but you have not explained the design clearly and there's no source code. There's no way to provide accurate assistance.
Can you explain the design? Are you trying to pass data between applications hosted on IIS?
All-Star
40565 Points
6233 Posts
Microsoft
Re: unable to use System.Web.Caching.Cache in server
Oct 11, 2018 07:00 AM|Fei Han - MSFT|LINK
Hi winseealn@hotmail.com,
I suspect that in elsewhere you get
cache["Key1"]
with null and convert it to other type or assign it to another variable etc, which might cause the issue.Besides, if you'd like to share data between multiple applications built with different languages (or platform), you can use Redis Cache etc. Or store the data in a temporary table in your database.
With Regards,
Fei Han
Member
297 Points
1356 Posts
Re: unable to use System.Web.Caching.Cache in server
Oct 15, 2018 10:50 AM|winseealn@hotmail.com|LINK
its resolved using System.Web.Caching.Cache cache = HttpRuntime.Cache;