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

  • SEARCH
  • Home
  • 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 7170399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:12:18+00:00 2026-05-28T15:12:18+00:00

I have found many questions here about storing values in viewstate, but haven’t found

  • 0

I have found many questions here about storing values in viewstate, but haven’t found a good answer.

I have a situation when i retrieve large amount of data from database. Then i filter and manipulate the data according to my needs (so it is a preety heavy process). Then I put the result inside a list of custom class. For example lets say this class will be Person

List<Person> persons = new List<Person>();

private void FillPersons()
{
   //Call to webservice
   persons = ws.GetPersonsList();

   //Do all kind of custom filtering

   //Manipulate the data

}

Now the whole FillPersons() method is a heavy process that returns pretty small amount of data. And unfortunately it can’t be moved to SQL and the heaviness is in the process, but that is not the point.

The point is that i need to reuse this data on the page between post backs.
Right now in order to spare the additional call to FillPersons() I mark Person class as serializeable and store the list in the viewstate, that works fine except the fact that the page becomes 1mb size because of the viewstate. According to what i have read, it is not so acceptable approach i.e. it is not secure and it blows the source code making the page heavy etc. (second is what most concerns me)

So it leaves me with a session. However session is persisted not only between postbacks, but much after it, even when user leaves the page. Or worst- the session will end before user decide to postback. So finding the best time span for session lifetime is mission impossible.

My question is what is the best practice to reuse “datasets” between postbacks?
What you guys do in such cases?

Thanks.

PS: hidden fields etc. is not an option.

  • 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-28T15:12:19+00:00Added an answer on May 28, 2026 at 3:12 pm

    You can store this kind of data in the Cache. It is application wide, so depending on what you add use the key accordingly.

    var key = UserID + "_personList";
    Cache.Add(key, personList, null, 
      DateTime.Now.AddSeconds(60), 
      Cache.NoSlidingExpiration,
      CacheItemPriority.High, 
      null);
    

    Note that you can never assume that the data is in the cache (it might have been flushed) so always check if it returns null and than refill it.

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

Sidebar

Related Questions

i found many related questions here. I have a simple java program . it
I have found many questions here on SO and articles all over the internet
I have been reading so many topics here about this, but I could not
I have refereed old questions and found that people face many issues after installing
I have found many people with simliar issues but no soultions...basically I have two
I know similar questions have been asked many times. But all I can find
I've found a few questions on modelling many-to-many relationships, but nothing that helps me
After reading through many of the questions here about DB schema migration and versions,
sorry to ask so many questions about SQL but I am doing exercises that
There are many similar questions, but I've tried about 15 different preg_match examples and

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.