A blog about SQL Server, SSIS, C# and whatever else I happen to be dealing with in my professional life.

Find ramblings

Thursday, January 28, 2010

Old school html and ASP.NET are not friends

I have not built a webpage in quite a few months but I wanted to sketch out a process flow so I could make sure the database components were positioned to support it.  Easy enough, built the screens but then I thought it'd be nifty to actually make a quick demo video showing how they would look to the end user.  I have Windows 7 with me and thanks to Twitter support, I fired up the Problem Step Recorder (psr.exe).  Edited my html and set the action to be the next page in the sequence.  Page 1 looks good, click the button to go to the next page and 
Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.

So what's the story?  No web farm or cluster here, just the simple visual studio IIS-lite process running.  I started trying things like setting EnableViewState to false everywhere but to no avail.  

My ultimate problem was I was mixing pure HTML and ASP.NET.  My form looked like
<form id="form1" runat="server" action="publishcomplete.aspx"><asp:Button ID="ButtonPublish" runat="server" Text="Publish data" /></form>

Google failed me and I was too lazy to look at previous solutions to see how I'd done it before.  Emasculated, I asked for help and my coworker, being the awesome one he is, gave me the appropriate level of grief along with the solution.  The action is old school and doesn't work mixed with ASP.NET controls.  Instead, move the action to the appropriate button and set the PostBackUrl property.
<form id="form1" runat="server"><asp:Button ID="ButtonPublish" runat="server" Text="Publish data" PostBackUrl="~/PublishComplete.aspx"/></form>

Problem solved and now on to better things

No comments: