Solved

InputBox causes ViewState Validation failure

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

680 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