473,721 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

actively resetting cache of web a method

Hello,

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

[WebMethod(Cache Duration=100)]
public DateTime TheTime()
{
return DateTime.Now;
}
[WebMethod]
public void ResetCache()
{
System.Reflecti on.MethodInfo mi = GetType().GetMe thod("TheTime") ;
object [] attributes = mi.GetCustomAtt ributes(false);
foreach( object objAttribute in attributes)
{
if( objAttribute is WebMethodAttrib ute)
{
WebMethodAttrib ute webmethodAttrib ute =
(WebMethodAttri bute)objAttribu te;
webmethodAttrib ute.CacheDurati on = 0;
//webmethodAttrib ute.CacheDurati on =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 1505
I believe that in order to do this you have to use the Context.Cache
(System.Web.Cac hing.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******** *************@j 73g2000cwa.goog legroups.com...
Hello,

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

[WebMethod(Cache Duration=100)]
public DateTime TheTime()
{
return DateTime.Now;
}
[WebMethod]
public void ResetCache()
{
System.Reflecti on.MethodInfo mi = GetType().GetMe thod("TheTime") ;
object [] attributes = mi.GetCustomAtt ributes(false);
foreach( object objAttribute in attributes)
{
if( objAttribute is WebMethodAttrib ute)
{
WebMethodAttrib ute webmethodAttrib ute =
(WebMethodAttri bute)objAttribu te;
webmethodAttrib ute.CacheDurati on = 0;
//webmethodAttrib ute.CacheDurati on =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
3235
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
4801
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 client which is executed by the exe. I am facing problem while executing the exe on the remote machine. If I start the exe manually everything works fine but if I execute it remotely through code using WMI an exception is thrown saying "No...
4
1716
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 is to call something like: MyDataType LocalVar = (MyDataType)Cache; Which works fine, but I'm having to put that code at the top of every method in my form that uses the cached data. It seems there must be a more elegant way to do this. I...
3
2929
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 callback method specified. 3) The callback method gets the newest version of the item from the db and then calls a helper method to put the item back into cache. It looks like this: //Pseudocode
4
1887
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 throught several pages. In the global.asax file i have the following code. Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs) ' Fires when the application is started
5
3228
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 then I thought it would be cleaner to maybe at the Cache code directly in the DAL. So, for example I might have a DAL method to get products that looks like this: public DataSet GetProducts() {
6
1990
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 ) { HttpContext.Current.Cache = GetCategoriesFromDB(); } return (DataView)HttpContext.Current.Cache;}
4
4077
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 have to click it twice to do the job (the first submit resets the sessions but this it too late to change the field values, which requires another submit to pick up the new session values). Problem is I cant think how to accomplish the resetting of...
11
12115
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 http-equiv="Expires" content="0"> <meta http-equiv="Pragma" content="no-cache"> <meta http-equiv="Cache-Control" content="no-cache"> This tags are part of the <headelement. Sample code that I have seen shows how to add metatags of the form:
0
8730
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9367
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9064
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6669
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5981
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4484
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3189
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2130
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.