如何显示asp.net缓存的内容? [英] How to display the content of asp.net cache?

查看:96
本文介绍了如何显示asp.net缓存的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个使用的HttpRuntime.Cache结果
对象保留一些静态查找值的asp.net MVC的Web应用程序。我们希望能够监控什么是实时的,使我们能够找出一些可能的缓存问题被缓存结果

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.

大多数缓存的项目是IEnumerable的的其中T可以是我们在结果
项目中使用的任何类或新的,最终可能被添加为该项目更进一步。结果
能有人给我如何做到这一点的指针?

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?

非常感谢你。

推荐答案

使用ASP.NET MVC本身。

Use ASP.NET MVC itself.

public ActionResult Index()
{
    return View(HttpRuntime.Cache)
}

和用于视图

Html.DisplayForModel()

您会希望使用自定义对象模板(基本上采取了MVC的模板,并关闭深度限制)。

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-部分3 - 默认templates.html

在该对象的模板,你会想要修改

On the object template you will want to alter

else if (ViewData.TemplateInfo.TemplateDepth > 1) { %>
    <%= ViewData.ModelMetadata.SimpleDisplayText %>



而> 1更改为是一个较大的数字像5-10,或只是完全删除这个深度检查(我可能会开始与5,并从那里)。

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).

这篇关于如何显示asp.net缓存的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆