473,388 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

actively resetting cache of web a method

Hello,

I am trying to reset the cache of a web method from code like this:

[WebMethod(CacheDuration=100)]
public DateTime TheTime()
{
return DateTime.Now;
}
[WebMethod]
public void ResetCache()
{
System.Reflection.MethodInfo mi = GetType().GetMethod("TheTime");
object [] attributes = mi.GetCustomAttributes(false);
foreach( object objAttribute in attributes)
{
if( objAttribute is WebMethodAttribute)
{
WebMethodAttribute webmethodAttribute =
(WebMethodAttribute)objAttribute;
webmethodAttribute.CacheDuration = 0;
//webmethodAttribute.CacheDuration =100;
}
}
}

My ResetCache() method should enforce the TheTime() method to reset but
this doesn't work. Does anybody know how to reset/flush the cache of a
web method from code?

Greetings,
Martijn Muurman

May 1 '06 #1
1 1497
I believe that in order to do this you have to use the Context.Cache
(System.Web.Caching.Cache) object to cache the data as opposed to the result
of the method call ...

You can even provide a dependency object to that cache.

Cheers,

Greg
<mm******@gmail.com> wrote in message
news:11*********************@j73g2000cwa.googlegro ups.com...
Hello,

I am trying to reset the cache of a web method from code like this:

[WebMethod(CacheDuration=100)]
public DateTime TheTime()
{
return DateTime.Now;
}
[WebMethod]
public void ResetCache()
{
System.Reflection.MethodInfo mi = GetType().GetMethod("TheTime");
object [] attributes = mi.GetCustomAttributes(false);
foreach( object objAttribute in attributes)
{
if( objAttribute is WebMethodAttribute)
{
WebMethodAttribute webmethodAttribute =
(WebMethodAttribute)objAttribute;
webmethodAttribute.CacheDuration = 0;
//webmethodAttribute.CacheDuration =100;
}
}
}

My ResetCache() method should enforce the TheTime() method to reset but
this doesn't work. Does anybody know how to reset/flush the cache of a
web method from code?

Greetings,
Martijn Muurman

May 1 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ben | last post by:
Hi all, I have written a web server that listens for requests: class MyHandler(BaseHTTPRequestHandler): def do_GET(self): if (self.path)=='/': data=makeList() else:
0
by: Data | last post by:
In my project I want to execute some commands on the remote machine. I am using .Net Remoting to achieve this. My server which is an exe is copied on the remote machine and it receives command from...
4
by: Jim Owen | last post by:
I am storing all my application data in the application cache. Anytime I have a method as part of an asp.net form, I need to access the objects in the cache. The only way I can think of to do this...
3
by: Brian Vallelunga | last post by:
I'm having a problem using the Cache object with asp.net. Here is what I have: 1) I put something in cache and set its callback method. 2) The object times out after X minutes and calls the...
4
by: Israel Ordonez Jr | last post by:
Hi everybody, I am having a problem with an ASP.NET application i am working on. I new to ASP.NET so I'm not sure if I'm doing this right. I am working on a website that has an oil price listed...
5
by: sklett | last post by:
Hi- I am having a hard time decided where I should be implementing my Cache code. I store most of the DataSet's that I need in the Cache. I was doing it in the bind method of my pages, but...
6
by: Charts | last post by:
I used HttpContext.Current.Cache To cache data from database. The code is like that. public static DataView GetCategories() { if ( HttpContext.Current.Cache == null ) {...
4
by: Ian Davies | last post by:
Hello I am struggling for a solution to clear some fields on my webpage that takes their values from some sessions My solution below works when the button is clicked twice. I sort of know why I...
11
by: EagleRed | last post by:
I am writing an ASP.NET 2.0 application that uses master pages. I have some pages that must not be cached on the client. In ASP.NET 1.1 I achieved this using metatags: <meta...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.