josgood
asked on
Server.Execute to a form, Response.Redirect back. The View State is invalid for this page and might be corrupted
I'm using Server.Execute to process a second web form
System.IO.StringWriter swrTarget = new System.IO.StringWriter();
Server.Execute("WebForm2.a spx",swrTa rget);
This brings up the second form just fine.
Then I use a button to return to the 1st form
Response.Redirect("WebForm 1.aspx");
When I do so, I get "The View State is invalid for this page and might be corrupted."
[HttpException (0x80004005): The View State is invalid for this page and might be corrupted.]
System.Web.UI.Page.LoadPag eStateFrom Persistenc eMedium()
System.Web.UI.Page.LoadPag eViewState ()
System.Web.UI.Page.Process RequestMai n()
Both forms have EnableViewStateMac="false" in their aspx. The second form does a Response.Write, but commenting it out does not fix the problem. WebForm1 and WebForm2 are the correct case-sensitive names. This is a very simple program -- I'm studying the Microsoft MCAD/MCSD book (Chapter 4, Lesson 3).
I'm stuck. Can someone help?
Thank you.
System.IO.StringWriter swrTarget = new System.IO.StringWriter();
Server.Execute("WebForm2.a
This brings up the second form just fine.
Then I use a button to return to the 1st form
Response.Redirect("WebForm
When I do so, I get "The View State is invalid for this page and might be corrupted."
[HttpException (0x80004005): The View State is invalid for this page and might be corrupted.]
System.Web.UI.Page.LoadPag
System.Web.UI.Page.LoadPag
System.Web.UI.Page.Process
Both forms have EnableViewStateMac="false"
I'm stuck. Can someone help?
Thank you.
Response.Redirect is just telling the client browser to load the page from scratch, so no form elements are posted, therefore, no ViewState is to be reconstructed as there is no postback occurring.
something else is happening.,
something else is happening.,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you, Bob. That's a good distinction to make.
To me, it seems that Server.Execute is more like starting another thread. The Server.Execute returns immediately -- it does not wait for the new form to open, be processed, and then close. Both the initial and second pages are active.
I'm using Server.Execute because that's what the book is covering in the section I'm reading.
To me, it seems that Server.Execute is more like starting another thread. The Server.Execute returns immediately -- it does not wait for the new form to open, be processed, and then close. Both the initial and second pages are active.
I'm using Server.Execute because that's what the book is covering in the section I'm reading.
ASKER
I just looked at the link provided by The Learned One. That told me exactly what I needed to do to debug this problem -- Response.Write in both forms. Just like using printf in the old days.
If I change
Server.Execute("WebForm2.a spx",swrTa rget);
to
Server.Execute("WebForm2.a spx");
then everything works great!
Don't know what the swrTarget is a problem, but that's another question.
Thank you for providing the way to find the solution, Bob. That's much more valuable than just the answer! Full marks.
If I change
Server.Execute("WebForm2.a
to
Server.Execute("WebForm2.a
then everything works great!
Don't know what the swrTarget is a problem, but that's another question.
Thank you for providing the way to find the solution, Bob. That's much more valuable than just the answer! Full marks.
Bob