I'm new to ASP.NET coding and need a little bit more help on correcting this form error.
This is the error I recieve everytime I fill out my contact form:
Server Error in '/' Application.
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.
Description: An
unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: 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.
Source Error:
The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:
1. Add a "Debug=true" directive at the top of the file that generated the error. Example:
<%@ Page Language="C#" Debug="true" %>
or:
2) Add the following section to the configuration file of your application:
<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration>
Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.
Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.
Stack Trace:
[ViewStateException: Invalid viewstate.
Client IP: 69.245.134.17
Port: 61833
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.56 Safari/537.17
ViewState: /wEPDwUJNDI0OTAyNzM4D2QWAgIDD2QWAgIBD2QWBAIDDxYCHiVDdXN0b21Db25uZWN0aW9uU3RyaW5nX1NlY3Rpb25Db250ZW50ZRYCZg9kFgQCAQ8PFgIeBFRleHQFCkNvbnRhY3QgVXNkZAIDDw8WAh8BBbcKPHA+Q29udGFjdCBVcy4gWW91ciBhY3R1YWwgdGV4dCB3aWxsIGJlIHNldCBzbyB0aGF0IGl0IGhhcyB0aGUgc2FtZSB2aXN1YWwgZWZmZWN0IGFzIHdoYXQgeW91IHNlZSBoZXJlLiAgV2UgdXNlIHRoaXMgdG8gc2hvdyB0aGUgc2l6ZSBhbmQgc3R5bGUgb2YgdHlwZSB0aGF0IHdpbGwgYmUgdXNlZCBpbiB0aGUgZmluYWwgcHJvZHVjdC4gIExvcmVtIGlwc3VtIGRvbG9yIHNpdCBhbWV0LCBjb25zZWN0ZXR1ZXIgYWRpcGlzY2luZyBlbGl0LCBzZWQgZGlhbSBub251bW15IG5pYmggZXVpc21vZCB0aW5jaWR1bnQgdXQgbGFvcmVldCBkb2xvcmUgbWFnbmEgYWxpcXVhbSBlcmF0IHZvbHV0cGF0LiAgVXQgd2lzaSBlbmltIGFkIG1pbmltIHZlbmlhbSwgcXVpcyBub3N0cnVkIGV4ZXJjaSB0YXRpb24gdWxsYW1jb3JwZXIgc3VzY2lwaXQgbG9ib3J0aXMgbmlzbCB1dCBhbGlxdWlwIGV4IGVhIGNvbW1vZG8gY29uc2VaYXQuPC9wPjxkaXYgY2xhc3M9InZjYXJkIj48YSBjbGFzcz0idXJsIGZuIiBocmVmPSJ...]
[HttpException (0x80004005): 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.]
System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError) +106
System.Web.UI.ViewStateException.ThrowMacValidationError(Exception inner, String persistedState) +14
System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +237
System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Deserialize(String serializedState) +4
System.Web.UI.Util.DeserializeWithAssert(IStateFormatter formatter, String serializedState) +37
System.Web.UI.HiddenFieldPageStatePersister.Load() +207
System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +105
System.Web.UI.Page.LoadAllState() +43
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6785
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +242
System.Web.UI.Page.ProcessRequest() +80
System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21
System.Web.UI.Page.ProcessRequest(HttpContext context) +49
ASP.contact_us_aspx.ProcessRequest(HttpContext context) +37
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
Version Information: Microsoft .NET Framework Version:2.0.50727.4234; ASP.NET Version:2.0.50727.4223
okay, I generated the new key and placed it inside the web.config file and now I get this error: (and the SMTP server address is correct I triple checked it)
Server Error in '/' Application.
The transport failed to connect to the server.
Description: An
unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: The transport failed to connect to the server.
Source Error:
Line 111: mm.Body = sScript
Line 112: System.Web.Mail.SmtpMail.SmtpServer = "mail.a-1door.com"
Line 113: System.Web.Mail.SmtpMail.Send(mm) Line 114:
Line 115: Response.Redirect("confirm.aspx")
Scratch that last message; Here's my script that reads the information from my contact form to send as an email:
<script language="vb" runat="server">
Sub FormSubmit(sender As Object, e As System.EventArgs)
Page.Validate()
If Not Page.IsValid Then
Return
End If
Dim sScript As String
sScript = "Name: " & txtName.Text.Trim() & vbCrLf
sScript = sScript & "Address: " & txtStreet.Text.Trim() & vbCrLf
sScript = sScript & "City: " & txtCity.Text.Trim() & vbCrLf
sScript = sScript & "State: " & listState.SelectedValue & vbCrLf
sScript = sScript & "Zip Code: " & txtZip.Text.Trim() & vbCrLf
sScript = sScript & "Email Address: " & txtEmail.Text.Trim() & vbCrLf
sScript = sScript & "Phone Number: " & txtPhone.Text.Trim() & vbCrLf
sScript = sScript & "Best time to Contact: " & txtContactTime.Text.Trim() & vbCrLf
sScript = sScript & "Comments: " & txtComments.Text.Trim() & vbCrLf
Dim mm As New System.Net.Mail.MailMessage
mm.To ="webadmin@a-1door.com";
mm.From = txtName.Text.Trim() & " <" & txtEmail.Text.Trim() & ">";
mm.Subject = "[A-1 Door] Contact Request";
mm.BodyFormat = System.Web.Mail.MailFormat.Text;
mm.Body = sScript;
SmtpClient sC = new SmtpClient("mail.a-1door.com");
sC.Port = 25;
sC.Send(mm)
<!--System.Web.Mail.SmtpMail.SmtpServer = "mail.a-1door.com"
System.Web.Mail.SmtpMail.Send(mm)-->
Response.Redirect("confirm.aspx")
End Sub
</script>
Here's the bottom line. I need this script to read my contact form and send the email to "webadmin@a-1door.com" using the SMTP server "mail.a-1door.com".
I am trying to convert this script from System.Web.Mail to System.Net.Mail. Port 25 is the correct port. How do I fix this script.
Please note that I inherited this website and did not write the original code. So I am a little confused when you get outside of editing web.config or this contact form script.
I am a complete stranger to ASP.NET so please be as elaborate as possible, Thank you in advance for your time and cooperation.
Jchapman65
None
0 Points
12 Posts
contact form keeps giving invalid MAC viewstate error
Feb 01, 2013 02:13 AM|LINK
I'm new to ASP.NET coding and need a little bit more help on correcting this form error.
This is the error I recieve everytime I fill out my contact form:
Server Error in '/' Application.
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.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: 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.
Source Error:
The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL: 1. Add a "Debug=true" directive at the top of the file that generated the error. Example: <%@ Page Language="C#" Debug="true" %> or: 2) Add the following section to the configuration file of your application: <configuration> <system.web> <compilation debug="true"/> </system.web> </configuration> Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode. Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.Stack Trace:
Version Information: Microsoft .NET Framework Version:2.0.50727.4234; ASP.NET Version:2.0.50727.4223
oned_gk
All-Star
30979 Points
6338 Posts
Re: contact form keeps giving invalid MAC viewstate error
Feb 01, 2013 02:47 AM|LINK
http://forums.asp.net/t/1785386.aspx/1?System+Web+HttpException+Validation+of+viewstate+MAC+failed
http://forums.asp.net/t/1751845.aspx/1?Validation+of+viewstate+MAC+failed
Jchapman65
None
0 Points
12 Posts
Re: contact form keeps giving invalid MAC viewstate error
Feb 01, 2013 12:34 PM|LINK
okay, I generated the new key and placed it inside the web.config file and now I get this error: (and the SMTP server address is correct I triple checked it)
Server Error in '/' Application.
The transport failed to connect to the server.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: The transport failed to connect to the server.
Source Error:
Line 111: mm.Body = sScript Line 112: System.Web.Mail.SmtpMail.SmtpServer = "mail.a-1door.com" Line 113: System.Web.Mail.SmtpMail.Send(mm) Line 114: Line 115: Response.Redirect("confirm.aspx")Source File: E:\HostingSpaces\a1admin\a-1door.com\wwwroot\contact-us.aspx Line: 113
Stack Trace:
Version Information: Microsoft .NET Framework Version:2.0.50727.4234; ASP.NET Version:2.0.50727.4223
and here's the chunk of code the error is referring to:
<!-- Smart Data Collection Form --> <script language="vb" runat="server"> Sub FormSubmit(sender As Object, e As System.EventArgs) Page.Validate() If Not Page.IsValid Then Return End If Dim sScript As String sScript = "Name: " & txtName.Text.Trim() & vbCrLf sScript = sScript & "Address: " & txtStreet.Text.Trim() & vbCrLf sScript = sScript & "City: " & txtCity.Text.Trim() & vbCrLf sScript = sScript & "State: " & listState.SelectedValue & vbCrLf sScript = sScript & "Zip Code: " & txtZip.Text.Trim() & vbCrLf sScript = sScript & "Email Address: " & txtEmail.Text.Trim() & vbCrLf sScript = sScript & "Phone Number: " & txtPhone.Text.Trim() & vbCrLf sScript = sScript & "Best time to Contact: " & txtContactTime.Text.Trim() & vbCrLf sScript = sScript & "Comments: " & txtComments.Text.Trim() & vbCrLf Dim mm As New System.Web.Mail.MailMessage mm.To = "joshc@atgfw.com" mm.From = txtName.Text.Trim() & " <" & txtEmail.Text.Trim() & ">" mm.Subject = "[A-1 Door] Contact Request" mm.BodyFormat = System.Web.Mail.MailFormat.Text mm.Body = sScript System.Web.Mail.SmtpMail.SmtpServer = "mail.a-1door.com" System.Web.Mail.SmtpMail.Send(mm) Response.Redirect("confirm.aspx") End Sub </script>oned_gk
All-Star
30979 Points
6338 Posts
Re: contact form keeps giving invalid MAC viewstate error
Feb 01, 2013 01:04 PM|LINK
Looks like connection problem. make sure you can connect in the server. Try connect using mail client or outlook.
Jchapman65
None
0 Points
12 Posts
Re: contact form keeps giving invalid MAC viewstate error
Feb 01, 2013 06:55 PM|LINK
is it coming up with the error because i'm using a different domain email address than the SMTP server?
I'm sending the email to "joshc@atgfw.com" but the SMTP server is: mail.a-1door.com, do I have to be using an "@a-1door.com" email address?
Jchapman65
None
0 Points
12 Posts
Re: contact form keeps giving invalid MAC viewstate error
Feb 01, 2013 09:28 PM|LINK
Scratch that last message; Here's my script that reads the information from my contact form to send as an email:
<script language="vb" runat="server"> Sub FormSubmit(sender As Object, e As System.EventArgs) Page.Validate() If Not Page.IsValid Then Return End If Dim sScript As String sScript = "Name: " & txtName.Text.Trim() & vbCrLf sScript = sScript & "Address: " & txtStreet.Text.Trim() & vbCrLf sScript = sScript & "City: " & txtCity.Text.Trim() & vbCrLf sScript = sScript & "State: " & listState.SelectedValue & vbCrLf sScript = sScript & "Zip Code: " & txtZip.Text.Trim() & vbCrLf sScript = sScript & "Email Address: " & txtEmail.Text.Trim() & vbCrLf sScript = sScript & "Phone Number: " & txtPhone.Text.Trim() & vbCrLf sScript = sScript & "Best time to Contact: " & txtContactTime.Text.Trim() & vbCrLf sScript = sScript & "Comments: " & txtComments.Text.Trim() & vbCrLf Dim mm As New System.Net.Mail.MailMessage mm.To ="webadmin@a-1door.com"; mm.From = txtName.Text.Trim() & " <" & txtEmail.Text.Trim() & ">"; mm.Subject = "[A-1 Door] Contact Request"; mm.BodyFormat = System.Web.Mail.MailFormat.Text; mm.Body = sScript; SmtpClient sC = new SmtpClient("mail.a-1door.com"); sC.Port = 25; sC.Send(mm) <!--System.Web.Mail.SmtpMail.SmtpServer = "mail.a-1door.com" System.Web.Mail.SmtpMail.Send(mm)--> Response.Redirect("confirm.aspx") End Sub </script>Here's the bottom line. I need this script to read my contact form and send the email to "webadmin@a-1door.com" using the SMTP server "mail.a-1door.com". I am trying to convert this script from System.Web.Mail to System.Net.Mail. Port 25 is the correct port. How do I fix this script.
Please note that I inherited this website and did not write the original code. So I am a little confused when you get outside of editing web.config or this contact form script.
I am a complete stranger to ASP.NET so please be as elaborate as possible, Thank you in advance for your time and cooperation.