Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6835847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:16:54+00:00 2026-05-26T23:16:54+00:00

I have a webmethod inside a webservice that calls another webservice to get data

  • 0

I have a webmethod inside a webservice that calls another webservice to get data and fills a generic list then it returns it, what i want to do is to save the list in memory, so the next time the webmethod is invoked it does not hit the other webservice but just returns the list, i have tried but when i invoke the web method for the second time the list count shows as 0, looks like garbage collection is cleaning all. any suggestions ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:16:55+00:00Added an answer on May 26, 2026 at 11:16 pm

    Store it in the ASP.NET cache. Setting an absolute expiration of midnight should assure that you only get it once per day (unless it gets tossed from the cache due to space issues).

     [Web Method]
     public List<Foo> GetFoos()
     {
          var foos = Cache["FooList"] as List<Foo>;
          if (foos == null)
          {
              ... get foos from remote web service ...
              var expiration = DateTime.Today.AddHours(7);
              if (DateTime.Now >= expiration)
              {
                  expiration = expiration.AddDays(1);
              }
              Cache.Insert( "FooList", foos, null, expiration, Cache.NoSlidingExpiration );
          }
    
          return foos;
     }
    

    Note: you could also use output caching as well, but you’re limited to a sliding expiration. That is, it will be cached for a duration based on when the request occurs. It’s not clear that’s what you want. For example, what if the first request occurs at 11pm with a 24 hour duration, you wouldn’t check again until 11pm the next day. If you have data changing on a daily basis, you’re better off using the ASP.NET cache in conjunction with output caching on a shorter duration to ensure that you get the latest, daily data in a timely fashion.

    Updated example based on comments.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a webmethod that returns the list of the Users althought the
I have some ASP.NET page and webservice WebMethod() methods that I'd like to add
I have a .NET webmethod that I have called from jQuery. The method returns
I have a gridview inside an updatepanel and I have a javascript that calls
I am writing a WebService using Java. Now I have a @WebMethod that is
I have a class CodeWithMessage that I want to return from my webservice as
I have a webmethod that returns a Hashtable through a jQuery ajax call along
Is it possible in jax-ws to have a webmethod that creates a new object
In C# I have methods that use [WebMethod(EnableSession = true)] I consume them in
I have a JSON response that is formatted from my C# WebMethod using the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.