Solved

InputBox causes ViewState Validation failure

Posted on 2008-10-02
2
240 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now