Asp – Under what circumstances might not be viewstate persisted

asp.net

I have a page and a user control inside it.

I assign a value to viewstate in the control and do

Server.Transfer(Request.Url.AbsolutePath);

but when I check the value on control's Page_Load() event the assigned value doesn't exists (viewstate is empty, has not keys).

Why might this happened?

Best Answer

ViewState is stored on per-page basis. As soon as you do a Server.Transfer you're going to lose the ViewState from the page you're transferring from, which seems to be where your control is located? ViewState is only persisted during postback.

Number two, you might be explicitly turning off the ViewState for a page or a single control and not realizing it.

Related Topic