We have an asp.net MVC web application which uses the HttpRuntime.Cache
object to keep some static lookup values. We want to be able to monitor what's
being cached in real time to allow us to pinpoint some possible caching issues.
Since this object isn't strongly typed when reading from it, we need to dynamically
cast each entries to it's concrete type.
Most of the cached items are of IEnumerable where T can be any classes we use in our
project or new ones that could eventually be added as the project goes further.
Can someone give me a pointer on how to do this?
Thank you very much.
Use ASP.NET MVC itself.
public ActionResult Index()
{
return View(HttpRuntime.Cache)
}
and for the view
Html.DisplayForModel()
You will want to use a custom object template (basically take the MVC template and turn off the depth restriction).
http://bradwilson.typepad.com/blog/2009/10/aspnet-mvc-2-templates-part-3-default-templates.html
On the object template you will want to alter
else if (ViewData.TemplateInfo.TemplateDepth > 1) { %>
<%= ViewData.ModelMetadata.SimpleDisplayText %>
And change the > 1 to either be a higher number like 5-10 or just completely remove this depth check (I'd probably start with a 5 and go from there).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With