Hello I have a small List<string> that I want to maintain across postbacks on only ONE page. The List will not contain more than 10 items, with each item being 40 chars max (no sensitive data).
I know that similar questions have been asked, but I am somewhat ambivalent between storing this in ViewState or Session. I’ve heard that even small string values can cause the ViewState value to increase quite largely in size. I would like to iterate through the List and use Linq to query it, but would I be better off using a string[] array, and would this List (of humble size) be okay to store in ViewState or should I be storing it in Session? Thank you.
Storing things in ViewState isn’t a terrible idea if you don’t abuse it. If the list is small and it only makes sense on one page, then go for it.
Just remember ViewState can be tampered with, so if you don’t want the client to know about it, then you are golden. Otherwise store it in Session.