Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / December 2006

Tip: Looking for answers? Try searching our database.

WebServices Webmethod Cacheduration

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Glenn Michael - 26 Nov 2006 23:57 GMT
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
Manish Bafna - 14 Dec 2006 09:24 GMT
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.

> Hi,
> What needs to be done to get Webmethod caching to work in the following
[quoted text clipped - 16 lines]
>     Return (dtReturn)
> End Function

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.