Error With Contact Form ASP.NET 3.5
Hi
If anyone tries to use the contact form and recieves an error, try this.
protected void cmdSubmit_Click(object sender, EventArgs e)
{
try
{
MailMessage msg = new MailMessage();
msg.IsBodyHtml = false;
msg.From = new MailAddress(txtEmail.Text, txtYourName.Text);
msg.To.Add(new MailAddress(Globals.settings.ContactForm.MailTo));
if (!string.IsNullOrEmpty(Globals.settings.ContactFor m.MailCC)) ;
msg.Subject = string.Format(Globals.settings.ContactForm.MailSub ject, ddlSubject.SelectedValue.ToString());
msg.Body = txtMessage.Text;
new SmtpClient().Send(msg);
lblFeedbackOK.Visible = true;
lblFeedbackKO.Visible = false;
}
catch(TypeInitializationException ex)
{
try
{
throw ex.InnerException;
}
finally
{
//return;
}
}
}
Notice the:
catch(TypeInitializationException ex)
{
try
{
throw ex.InnerException;
}
If you get the following error:
Parser Error Message: An error occurred creating the configuration section handler for *******: Could not load file or assembly '_code' or one of its dependencies. The system cannot find the file specified.
Remove _code from the web config file:
<section name="theBeerHouse" type="MB.TheBeerHouse.TheBeerHouseSection"/>
And it should work OK, not sure why as if i run the beerhouse in ASP.NET 2.0 it works ok, but not in ASP.NET 3.5
George
|