Link to home
Start Free TrialLog in
Avatar of dageyra
dageyraFlag for United States of America

asked on

InputBox causes ViewState Validation failure

I am getting an error in my VB code: "Validation of viewstate MAC failed".  Note that I am NOT using a cluster environment, the viewstate mac failure seems to be a "catchall" error message for Microsoft, so the error message has no helpful information.

To see the error goto: http://www.thedesk.info/myplan/printerFriendlyTop2.aspx?domain=community&pageToPrint=print.aspx
then click "Email".  All of the other options work.

I have determined that by removing a call to InputBox, the error goes away.  Also, the error states that I can get more information by making debug="true", but it is both globally and in the page.

Does anyone know why a call to InputBox would cause this error and how I can get around it?  My web.config is as follows:

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Web.Config Configuration File -->

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
    <system.web>
        <customErrors mode="Off"/>
                        <pages validateRequest="false" enableEventValidation="false" viewStateEncryptionMode ="Never" />
        <compilation debug="true"/>
          </system.web>
</configuration>
<%@ Page Language="VB"%>
<script language="VB" runat="Server">
 
...
 
  Sub SendEmail(ByVal sender As Object, ByVal e As System.EventArgs)
    Dim email As String = InputBox("Please enter your email address")
    Dim pageToLoad As String = "print.aspx?domain=" & domain.Value & "&userName=" & userName.Value
    Dim tx As New System.IO.StringWriter
    Server.Execute(pageToLoad, tx)
	  
    Dim ct As System.Net.Mime.ContentType = New System.Net.Mime.ContentType(System.Net.Mime.MediaTypeNames.Text.Html)
    Dim plan As Net.Mail.Attachment = Net.Mail.Attachment.CreateAttachmentFromString(tx.ToString(), ct)
    plan.ContentDisposition.FileName = "myplan_" & domain.Value & ".html"
    plan.ContentDisposition.DispositionType = System.Net.Mime.MediaTypeNames.Text.Html
		
    Dim msg As String = "Your plan is attached"
    GeneralFunctionsVB.mail(email, "MyPlan", "myplan@thedesk.info", msg, Nothing, Nothing, 0, plan)
  End Sub
</script>
 
...
 
<!-- The .NET code for handling the Email link -->
<asp:LinkButton ID="EmailLink" runat="server" CssClass="actionLink" OnClick="SendEmail">Email...</asp:LinkButton>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of NazoUK
NazoUK
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dageyra

ASKER

HI:

I wanted to let you know that I worked it out with JavaScript, you were right, the InputBox would not work--though I am still confused as to why it generates a "ViewState" failure.