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 8037537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:57:31+00:00 2026-06-05T02:57:31+00:00

I was thinking about if a custom made ViewState variable is always available on

  • 0

I was thinking about if a custom made ViewState variable is always available on each page visit (same browser session) (like Session but client-side) or only at a page postback? I know this is client-side data that is always encapsulated with the Request packet and the Response packet from the server.

I was testing this right now, and I did the following:

on Home.aspx:

protected void Page_Load(object sender, EventArgs e)
{
    ViewState["test"] = "test1";
}
protected void Button1_Click(object sender, EventArgs e)
{
    string test = ViewState["test"].ToString();

    Server.Transfer("Default.aspx");
}

And on Default.aspx:

protected void Page_Load(object sender, EventArgs e)
{
    string test = ViewState["test"].ToString();
}

But I get NullReferenceException. So it means that ViewState["test"] doesn’t exists because the ViewState is completely new and regenerated. So my conclusion is that you can use ViewState variables only when doing a form postback (but in fact, you do always a redirect after a form postback, so I can’t use ViewState always…).

Am I right with my opinion?

  • 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-06-05T02:57:33+00:00Added an answer on June 5, 2026 at 2:57 am

    ViewState can be configured in different ways, with different (or custom) providers, or can be completely disabled. However, the default provider is that it is a form-field, so yes: in that default configuration case it will only exist on a POST, and will not exist for a GET. A transfer operates essentially like a GET.

    If you need data between unrelated pages, but user-related – use session-state, or something cookie-based.

    In unrelated news: view-state is pretty horrible in many ways – think of the kittens!

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

Sidebar

Related Questions

I'm thinking about making a simple web application to practice custom tags, EL, ...
I'm thinking about possibility to put into AndroidManifest.xml some custom data. E.g. version of
I am thinking about building a project, that in the name of custom expanding
I'm thinking about using custom attributes in Jquery to avoid using class or id
We are currently thinking about different ways to implement custom fields for our web
I'm working on a custom CMS for my own use and was thinking about
Thinking about avoiding code replication, I got a question that catches me every time
Thinking about if we modify the definition of Hamiltonian path as we need to
Been thinking about this for hours now. Im building a simple slideshow application, where
Just thinking about the best way to build an Order form that would (from

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.