Solved

InputBox causes ViewState Validation failure

Posted on 2008-10-02
2
246 Views
Last Modified: 2013-11-07
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

0
Comment
Question by:dageyra
2 Comments
 
LVL 15

Accepted Solution

by:
NazoUK earned 500 total points
ID: 22628635
You can't use InputBox in an asp.net page, how would it work?
Put a textbox on your page, if necessary to have it as a pop-up you'll need to do it with javascript or the modalpopupextender from the ajax toolkit or something similar.
0
 
LVL 1

Author Comment

by:dageyra
ID: 22672632
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.  
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

776 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