How to display asp.net cache contents?

We have an asp.net MVC web application that uses an HttpRuntime.Cache
object to store some static search values. We want to be able to track what is cached in real time so that we can identify some possible caching issues.

Since this object cannot be read on the hard drive while reading, we need to dynamically attach all the records to it with a specific type.

Most cached items have IEnumerable, where T can be any class that we use in our project or new ones that can ultimately be added as the project progresses.
Can someone give me a pointer on how to do this?

Many thanks.

+5
source share
4 answers

Use ASP.NET MVC itself.

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

and for presentation

Html.DisplayForModel()

You will need a custom object template (basically, take the MVC template and turn off the depth limit).

http://bradwilson.typepad.com/blog/2009/10/aspnet-mvc-2-templates-part-3-default-templates.html

In the object template you will want to change

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

And change the value> 1 to a larger number, like 5-10, or just completely remove this depth check (I probably start at 5 and go from there).

+4
source

Json JavaScriptSerializer. , , Serialize - JSON. , , Newtonsoft Json.NET.

+1

, - MVC, , , , , MVC.

0

, , , , - , - , .

, , , :

object obj= new List<string>();
Type type = obj.GetType();

Type enumerable = type.GetInterfaces().FirstOrDefault(t => t.IsGenericType && t.GetGenericTypeDefinition() == typeof(IEnumerable<>));
if (enumerable != null)
{
    Type listType = enumerable.GetGenericArguments()[0];
    if (listType == typeof(string))
    {
        IEnumerable<string> e = obj as IEnumerable<string>;
    }
}

, ?

, Perfmon - "# Entries" ( , , ), , , , , - , , .

Perfmon , , ( , , IEnumerable, ) - , "" perfmon , ( "_Total" ).

Perfmon .

0

All Articles