System.Web.Caching.Cache returning null for a key in the cache

I have some code(client side) that is trying to cache responses from a web service. I save the responses in a System.Web.Caching.Cache object gotten from System.Web.HttpRuntime.

I make a call once, then i make it again and have a console output saying it loaded from cache. But I am never getting the console output. I ran it in a debugger and put a break point at the Get and the Cache as the entry and the key inside the cache is the same as the key I'm passing into the get but it still returns null?????

basically the code looks like this.

public object MakeRequest(string uri) { (break point)object retList = Querier.Cache.Get(uri); if (retList != null) { Console.WriteLine("Loaded from Cache"); } retList = Querier.MakeRequest(uri); Querier.Chache[uri] = retList; return retList; }

Querier is an object that makes my http request and deserializes the object then returns it.

Anyone have an idea about why the cache is returning null and not the object stored in it? this one has me at a loss because the debugger shows that both the internal key and the one I'm passing in are the same string(although not formed at the same place) Thanks in advance

-------------Problems Reply------------

So it turns out i didn't look quite close enough at the two strings and one was slightly diffrent fromt he other, they both went to the same webpage but weren't equal by string comparor method.

Category:c# Views:1 Time:2010-06-21
Tags: c# caching client

Related post

  • Why does System.getProperty("line.seperator") return null? 2011-04-11

    Exactly as the title asks, why is System.getProperty("line.seperator") returning null. From looking around I gather that it shouldn't. Running this code shows that it seems to be set as the line with the separator is broken: class Test { public stati

  • MVC 2 with Entity Data Model returning Null for foreign keys 2011-04-11

    I am creating my first MVC 2 applicaiton. I've followed expamples in the books I have and created an ADO.NET Entity Data Model that auto generated the model.edms and model.designer.cs files. I then created a repository.cs file in my model folder to s

  • ASP.NET Cache always returns null 2013-08-30

    I am using SQLCacheDependency in my ASP.NET application with Query Notifications. I followed this article to set up my database with success.However whenever I am trying to store data in the cache object.It just does not hold value.It is always null

  • Querying an IQuery from a cached list returns null exception 2011-01-30

    I've been experimenting with Peter Montgomery's "Caching the results of LINQ queries" source listed here which creates an extension method for IQueryable<T> returning an IEnumerable<T> from cached data if possible. The main extension meth

  • Overriding System.Web.Mvc.ViewMasterPage, where to make call to grab from cache? 2008-11-20

    I need to grab a value from the HttpCOntext.Items request cache, where should I do this? Is there a particular event or contsructor I should override? --------------Solutions------------- ViewMasterPage is a subclass of Control; and you should be abl

  • Asp.net System.Web.HttpContext.Current.Session null in global.asax 2008-11-16

    I have a custom security principal object which I set in the global.asax for the current thread and all is well, no problems normally. However, I'm just adding a dynamic image feature by having a page serve up the image and whenever that dynamic imag

  • Asynchronous web service call returning null (called from ASP.NET asynchronous page) 2009-12-11

    I am consuming a 3rd-party web service which has been implemented in WCF. My consumer code resides on an ASP.NET asynchronous page. Problem is, sometimes the BeginCallWebService() method is returning null. Shouldn't it always return an IAsyncResult o

  • System.Windows.Application.GetResourceStream returns null 2010-01-26

    If I debug a WPF-application with Catalog.xaml as Content, I can't get the resource stream of it - GetResourceStream returns null: var uri = new Uri("/Assembly;component/Catalog.xaml", UriKind.Relative); var foo = System.Windows.Application.GetResour

  • System.Web.VirtualPath implementation returns attachment, doesn't render 2010-11-22

    I have an implementation of a ASP.NET MVC 3 RC site where I load in parts of the site from external assemblies. I've written implementations for VirtualPath as well as VirtualFile that catches the requests for files in these assemblies and gets them

  • System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerWrapper Null Reference 2010-11-29

    I get the following error randomly when running an ASP.NET MVC 2 project. This error occurs on different pages at different times. Cannot reproduce this error or identify pattern of when and on which page the error occurs. System.Web.HttpException: E

  • Why would System.Type.GetType("Xyz") return null if typeof(Xyz) exists? 2010-09-21

    I have come across a strange behaviour in my (huge) .NET 4 project. At some point in the code, I am referring to a fully qualified type, say: System.Type type = typeof (Foo.Bar.Xyz); later on, I do this: System.Type type = System.Type.GetType ("Foo.B

  • WP7 - web service calls return null instead of collections 2011-06-28

    I want to consume a webservice and particulary a method which return a collection. When i consume it by using a console application, it works. But when I try to consume it with a WP7 App, i only get a null object or empty list. I have try to get a si

  • NSDictionary returning null value for key 2012-02-23

    Im having trouble understanding why the following code displays "The First Key = (null)" in the console/terminal: Here is the Interface: #import <UIKit/UIKit.h> @interface TestingViewController : UIViewController @property (nonatomic, strong) N

  • Java: System.getenv("APPDATA") returns null, now what? 2011-04-23

    I just found out that when a Java program is launched on Windows via "Run As..." (from the executable's context menu) as a different user, a call to System.getenv("APPDATA") will return null, rather than the usual application data folder. Now, I'm ki

  • Is there any way to construct System.Web.Services.Protocols.InvokeCompletedEventArgs? 2011-09-30

    This is possibly a dumb question since I'm new to all the technologies I'm using here (C#, .NET and SOAP). There just may not be anyway to do what I want to do here. I've got an asynchronous SOAP call (code generated from WSDL) that I'm trying to alt

  • Webmethod using HttpContext returns null reference exception 2010-11-22

    It is a web method running via .asmx page: Quick summary: [WebMethod] Method Name { string Port=HttpContext.Current.Request.ServerVariables["SERVER_PORT"]; if (Port == null || Port == "80" || Port == "443") { Port = ""; } else { Port = ":" + Port; }

  • Could not load type "System.Web.HttpContext" from assembly "System.Web" 2011-02-07

    System.TypeLoadException: Could not load type 'System.Web.HttpContext' from assembly 'System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. using System; using System.Collections; using System.Collections.Generic; using Syst

  • Why System.getProperty doesn't return value from System variables in windows 2014-02-20

    I have this system variable this code: System.out.println(System.getProperty("area")); returns null. Could I get acces to system variables from java code through System.getProperty method ? P.S --------------Solutions------------- This is not a syste

  • Return null by reference via __get() 2011-05-11

    Quick specs: PHP 5.3 error_reporting(-1) // the highest I'm using the __get() by reference trick to magically access arbitrarily deep array elements in an object. Quick example: public function &__get($key){ return isset($this->_data[$key]) ?

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.110 (s). 11 q(s)