How to display the content of asp.net cache?

后端 未结 4 1275
我在风中等你
我在风中等你 2021-01-12 15:04

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

4条回答
  •  青春惊慌失措
    2021-01-12 15:48

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

提交回复
热议问题