Loosing ViewState on postback

G

Gauthier Segay

Hello,

I've problem on subsequent postbacks after a Server.Transfer was done.
In our application framework we have a method that pass parameters (via
HttpContext.Items) and navigate to another page (via Server.Transfer),
this work nicely for what it's done for: passing parameters to another
page.

Now my problem is on the destination page, If I affect something to the
viewstate, it's available in the statebag during the current request,
but subsequent postback on the same page loose my viewstate.

Here is a simple stepped exemple to expose my problem in a more
synthetic manner:

========8<============8<============
Page1:
[STEP1] Page_Init...Page_Load...Page_Render... User click on Btn1
[STEP2] Page_Init...Btn1_Click...Server.Transfer

Page2:
[STEP3] Page_Init...Page_Load...Page_Render... User click on Btn1
[STEP4] Page_Init...Btn1_Click... nothing in viewstate
========8<============8<============

Clearly, if I put something in viewstate during step3, I got nothing in
it during step4.

It seems to be an asp.net bug.

Do you have a solution or workarround? (I don't want to rely on Session
variables).

Thanks

Gauthier Segay
 
G

Grant Merwitz

Just a test,

If you change the Server.Transfer to Response.Redirect,
does the ViewState work properly then?
 
O

Onin Tayson

also try Server.Transfer("url.aspx", true)

Grant Merwitz said:
Just a test,

If you change the Server.Transfer to Response.Redirect,
does the ViewState work properly then?


Gauthier Segay said:
Hello,

I've problem on subsequent postbacks after a Server.Transfer was done.
In our application framework we have a method that pass parameters (via
HttpContext.Items) and navigate to another page (via Server.Transfer),
this work nicely for what it's done for: passing parameters to another
page.

Now my problem is on the destination page, If I affect something to the
viewstate, it's available in the statebag during the current request,
but subsequent postback on the same page loose my viewstate.

Here is a simple stepped exemple to expose my problem in a more
synthetic manner:

========8<============8<============
Page1:
[STEP1] Page_Init...Page_Load...Page_Render... User click on Btn1
[STEP2] Page_Init...Btn1_Click...Server.Transfer

Page2:
[STEP3] Page_Init...Page_Load...Page_Render... User click on Btn1
[STEP4] Page_Init...Btn1_Click... nothing in viewstate
========8<============8<============

Clearly, if I put something in viewstate during step3, I got nothing in
it during step4.

It seems to be an asp.net bug.

Do you have a solution or workarround? (I don't want to rely on Session
variables).

Thanks

Gauthier Segay
 
G

Gauthier Segay

Hello,

I suppose this will work, but I can't test in my current context since
I will lose the HttpContext.Items parameters.

I think the problem is that the viewstate work for a given url, and
this url is not refreshed while using Server.Transfer.

Thanks for your proposition.

Gauthier Segay

Grant said:
Just a test,

If you change the Server.Transfer to Response.Redirect,
does the ViewState work properly then?


Gauthier Segay said:
Hello,

I've problem on subsequent postbacks after a Server.Transfer was
done. In our application framework we have a method that pass
parameters (via HttpContext.Items) and navigate to another page
(via Server.Transfer), this work nicely for what it's done for:
passing parameters to another page.

Now my problem is on the destination page, If I affect something to
the viewstate, it's available in the statebag during the current
request, but subsequent postback on the same page loose my
viewstate.

Here is a simple stepped exemple to expose my problem in a more
synthetic manner:

========8<============8<============
Page1:
[STEP1] Page_Init...Page_Load...Page_Render... User click on Btn1
[STEP2] Page_Init...Btn1_Click...Server.Transfer

Page2:
[STEP3] Page_Init...Page_Load...Page_Render... User click on Btn1
[STEP4] Page_Init...Btn1_Click... nothing in viewstate
========8<============8<============

Clearly, if I put something in viewstate during step3, I got
nothing in it during step4.

It seems to be an asp.net bug.

Do you have a solution or workarround? (I don't want to rely on
Session variables).

Thanks

Gauthier Segay
 
G

Gauthier Segay

Hello,

The problem is the same, and in fact, the overload without the boolean
is passing true by defaul (I've checked with reflector).

Do anyone have another idea?

Do you agree that this is a bug in ASP.NET's ViewState handling?

Gauthier Segay

Onin said:
also try Server.Transfer("url.aspx", true)

Grant Merwitz said:
Just a test,

If you change the Server.Transfer to Response.Redirect,
does the ViewState work properly then?


Hello,

I've problem on subsequent postbacks after a Server.Transfer was
done. In our application framework we have a method that pass
parameters (via HttpContext.Items) and navigate to another page
(via Server.Transfer), this work nicely for what it's done for:
passing parameters to another page.

Now my problem is on the destination page, If I affect something
to the viewstate, it's available in the statebag during the
current request, but subsequent postback on the same page loose
my viewstate.

Here is a simple stepped exemple to expose my problem in a more
synthetic manner:

========8<============8<============
Page1:
[STEP1] Page_Init...Page_Load...Page_Render... User click on Btn1
[STEP2] Page_Init...Btn1_Click...Server.Transfer

Page2:
[STEP3] Page_Init...Page_Load...Page_Render... User click on Btn1
[STEP4] Page_Init...Btn1_Click... nothing in viewstate
========8<============8<============

Clearly, if I put something in viewstate during step3, I got
nothing in it during step4.

It seems to be an asp.net bug.

Do you have a solution or workarround? (I don't want to rely on
Session variables).

Thanks

Gauthier Segay
 
G

Grant Merwitz

Just reading this article

http://support.microsoft.com/default.aspx?id=kb;en-us;Q316920

I know its not the same error, but maybe worth a try
So, Try set EnableViewStateMac to true for your site, and see if it makes a
difference


Gauthier Segay said:
Hello,

I suppose this will work, but I can't test in my current context since
I will lose the HttpContext.Items parameters.

I think the problem is that the viewstate work for a given url, and
this url is not refreshed while using Server.Transfer.

Thanks for your proposition.

Gauthier Segay

Grant said:
Just a test,

If you change the Server.Transfer to Response.Redirect,
does the ViewState work properly then?


Gauthier Segay said:
Hello,

I've problem on subsequent postbacks after a Server.Transfer was
done. In our application framework we have a method that pass
parameters (via HttpContext.Items) and navigate to another page
(via Server.Transfer), this work nicely for what it's done for:
passing parameters to another page.

Now my problem is on the destination page, If I affect something to
the viewstate, it's available in the statebag during the current
request, but subsequent postback on the same page loose my
viewstate.

Here is a simple stepped exemple to expose my problem in a more
synthetic manner:

========8<============8<============
Page1:
[STEP1] Page_Init...Page_Load...Page_Render... User click on Btn1
[STEP2] Page_Init...Btn1_Click...Server.Transfer

Page2:
[STEP3] Page_Init...Page_Load...Page_Render... User click on Btn1
[STEP4] Page_Init...Btn1_Click... nothing in viewstate
========8<============8<============

Clearly, if I put something in viewstate during step3, I got
nothing in it during step4.

It seems to be an asp.net bug.

Do you have a solution or workarround? (I don't want to rely on
Session variables).

Thanks

Gauthier Segay
 
G

Gauthier Segay

Hello,

I've set this property to true in my base page class, seeing not any
change in behavior.

Thanks for suggesting.

Does anyone have other suggestions?

Does any Microsoft folks is aware of my issue?

Thanks,

Gauthier Segay

Grant said:
Just reading this article

http://support.microsoft.com/default.aspx?id=kb;en-us;Q316920

I know its not the same error, but maybe worth a try
So, Try set EnableViewStateMac to true for your site, and see if it
makes a difference


Gauthier Segay said:
Hello,

I suppose this will work, but I can't test in my current context
since I will lose the HttpContext.Items parameters.

I think the problem is that the viewstate work for a given url, and
this url is not refreshed while using Server.Transfer.

Thanks for your proposition.

Gauthier Segay
to >>> the viewstate, it's available in the statebag during the
current >>> request, but subsequent postback on the same page loose my
viewstate.

Here is a simple stepped exemple to expose my problem in a more
synthetic manner:

========8<============8<============
Page1:
[STEP1] Page_Init...Page_Load...Page_Render... User click on Btn1
[STEP2] Page_Init...Btn1_Click...Server.Transfer

Page2:
[STEP3] Page_Init...Page_Load...Page_Render... User click on Btn1
[STEP4] Page_Init...Btn1_Click... nothing in viewstate
========8<============8<============

Clearly, if I put something in viewstate during step3, I got
nothing in it during step4.

It seems to be an asp.net bug.

Do you have a solution or workarround? (I don't want to rely on
Session variables).

Thanks

Gauthier Segay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top