WebServices Webmethod Cacheduration

G

Glenn Michael

Hi,
What needs to be done to get Webmethod caching to work in the following
code? The code returns data but does not cache as expected. I'm using Ajax
Beta 2. Is this enough information? Thanks in advance for your help.


'ONE OF MANY CALLING WEB SERVICE
Public Sub subWebServiceCall()
Dim qdt As New DataTable
Dim pageWebService As New ws.csasWS 'NAME SPACE & WS PAGE NAME
qdt = pageWebService.funcWS() 'FUNCTION CALLED IN WEBSERVICE
Call subContinue(qdt )
End Sub

'WEB-METHOD IN WEB-SERVICE
<WebMethod(CacheDuration:=10)> _
Public Function funcWS() As DataTable
Dim dtReturn As DataTable
dtReturn = funcGetData()
Return (dtReturn)
End Function
 
M

Manish Bafna

Hi,
You are using Output Cache which I think is not appropriate in your
scenario.I feel you should use Cache Object(That is data cache)
I am explaining how you can do it:

public DataTable Function funcWS()
{
if((DataTable)Cache["UniqueKey"] == null)
{
Cache.Insert("UniqueKey", myData, null, DateTime.Now.AddMinutes(10),
System.Web.Caching.Cache.NoSlidingExpiration);
}
else
{
return (DataTable)Cache["UniqueKey"] ;
}
}
Here myData is DataTable returned by your SQL Query.
I have written the code in C#.If you have doubts then feel free to ask.

Thanks and Regards,
Manish Bafna
MCP and MCTS.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,539
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top