mabeiyi
mabeiyi

Reputation: 367

ASP.NET: About storing Objects in ViewState

If I want the object be persisted across postbacks, is it a good idea to store Object in ViewState? Are there any better ideas? I am afraid the size of ViewState is too large...

Upvotes: 0

Views: 2938

Answers (1)

Jude Cooray
Jude Cooray

Reputation: 19862

If the object is too large, ViewState is a bad idea. Also there are other considerations regarding storing the information in the ViewState like security and how long you want the information to persist.

See ASP.NET State Management Overview for what other options you have.

Check ASP.NET State Management Recommendations to determine what to use in different scenarios.

I once stored a DataTable (facepalm) in the view state and was wondering why it took so much time load the page in a mobile browser. Storing it in session was MUCH faster because the page was not bloated with unnecessary objects.

Upvotes: 5

Related Questions