Can I clear the ASP.NET application cache without resetting AppDomain?

I would like to reset / clear the item in the cache, but without resetting the application or writing a specialized page just for that. those. non-software solution. Is it possible?

+3
source share
3 answers

Short answer: None.

The ASP.NET cache does not have an administration interface to manage it. You will need to recycle the application pool or create a simple page Delete items from the cache in ASP.NET .

EDIT : Inspired by Mick, you can have a page like this ( RemoveCache.aspx):

<%@ Page Language="C#" %>
<script runat="server">

    void Page_Load(object sender, EventArgs e)
    {
        if (String.IsNullOrEmpty(Request.QueryString["name"]))
        {
            foreach (DictionaryEntry item in Cache)
            {
                Cache.Remove(item.Key.ToString());
                Response.Write(item.Key.ToString() + " removed<br />");
            }
        }
        else
        {
            Cache.Remove(Request.QueryString["name"]);
        }
    }

</script>

RemoveCache.aspx, ; RemoveCache.aspx?name=Products, Products.

+8
            Dim CacheKeys As New List(Of String)
            For Each CacheItem As DictionaryEntry In Cache
                CacheKeys.Add(CacheItem.Key)
            Next

            For Each Key As String In CacheKeys
                Cache.Remove(Key)
            Next

, , . - FormsAuthentication, -, , URL- , . -, , , - , . Cachability NoCache , GridViews, DataBound, , "". .

+2

VB.NET, ?

For Each de As DictionaryEntry In HttpContext.Current.Cache

HttpContext.Current.Cache.Remove(DirectCast(de.Key, String))

Next

+1

Source: https://habr.com/ru/post/1731124/


All Articles