?
Solved

Server.Execute to a form, Response.Redirect back.  The View State is invalid for this page and might be corrupted

Posted on 2005-05-02
5
Medium Priority
?
815 Views
Last Modified: 2010-05-18
I'm using Server.Execute to process a second web form
    System.IO.StringWriter swrTarget = new System.IO.StringWriter();
    Server.Execute("WebForm2.aspx",swrTarget);
This brings up the second form just fine.

Then I use a button to return to the 1st form
            Response.Redirect("WebForm1.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.LoadPageStateFromPersistenceMedium()
   System.Web.UI.Page.LoadPageViewState()
   System.Web.UI.Page.ProcessRequestMain()

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.
0
Comment
Question by:josgood
  • 2
  • 2
5 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 13909672
With Server.Execute the page executes like a subroutine.  If you want control to pass to the new form, use Server.Transfer instead.

Bob
0
 
LVL 23

Expert Comment

by:b1xml2
ID: 13909697
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.,
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 800 total points
ID: 13909701
The Execute Method:
http://www.w3schools.com/asp/met_execute.asp

The Execute method executes an ASP file from inside another ASP file. After executing the called .asp file, the control is returned to the original .asp file.

Bob

0
 
LVL 13

Author Comment

by:josgood
ID: 13909725
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.
0
 
LVL 13

Author Comment

by:josgood
ID: 13909809
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.aspx",swrTarget);
to
    Server.Execute("WebForm2.aspx");
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.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month15 days, left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question