WebServices Webmethod Cacheduration

Discussion in 'ASP .Net Web Services' started by Glenn Michael, Nov 26, 2006.

  1. 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
    Glenn Michael, Nov 26, 2006
    #1
    1. Advertising

  2. Glenn Michael

    Manish Bafna Guest

    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.



    "Glenn Michael" wrote:

    > 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, Dec 14, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. usamedb208

    CacheDuration is not working

    usamedb208, Jan 29, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    498
    usamedb208
    Jan 29, 2004
  2. Arpan

    CacheDuration In WebService?

    Arpan, Sep 5, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    506
    Arpan
    Sep 5, 2006
  3. Manuel Trunk

    problem with CacheDuration attribute

    Manuel Trunk, Nov 4, 2003, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    123
    Manuel Trunk
    Nov 4, 2003
  4. Tim Scarfe

    ASP.NET Web Services. Web Method CacheDuration Issue.

    Tim Scarfe, Feb 4, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    108
    Tim Scarfe
    Feb 4, 2004
  5. Francis Shanahan

    CacheDuration from Internet explorer

    Francis Shanahan, Dec 28, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    143
    Francis Shanahan
    Dec 28, 2004
Loading...

Share This Page