View Single Post
  #1 (permalink)  
Old September 13th, 2007, 12:24 PM
garrettbrennan garrettbrennan is offline
Registered User
Join Date: Sep 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Need to send email

Firstly, I'm not sure I'm posting this query in the correct forum. Apologies if I got it wrong.
I am designing a simple web page using C# in Microsoft Visual Web Developer. All I want is a form witha few fields and a button. On clicking this button I want to generate an email to me (administrator).
I have searched for various solutions on the internet and have tried most of them.

No matter what solution I try (to send email when button clicked) I get the same error:

" 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. "

When I search for this error, the comments all relate to web farms etc. (whatever they are).

Can I just explain a little bit here (please be patient).

I suspect the problem is related to the fact that I am testing / running the code on my PC - i.e. not uploading it to a server.

An example of the code that I'm using (when button clicked) is:


<%@ Import Namespace="System.Net.Mail" %>

<script runat="server">

    protected void buttonSend_Click(object sender, EventArgs e)
        MailAddress from = new MailAddress("");
        MailAddress to = new MailAddress("");
        MailMessage message = new MailMessage(from, to);
        message.Subject = "Using the SmtpClient class.";
        message.Body = @"Using this feature, you can send an e-mail message from an application very easily.";
        SmtpClient client = new SmtpClient("localhost");


where email1 and email2 are two of my own email addresses. Also, instead of "localhost" I'ce also tried "" and "" (where myserver is my real ISP).

Also, I've updated my web.config a few times with various combinations of parameters.

No matter what solutions I find and try, I keep getting the same error when I click on the button. As I say, I'm guessing it might be because I'm trying to test the code on my PC. Uploading to a server is not an option at the moment.

Have you any suggestions. My other option is to take 3 months out and study C# and Visual Web Developer in depth - but I'm hoping just to get past this hurdle and move on for now...


Garrett Brennan