UPDATE: See my second post for updated situation
I had set up a "Contact Us" page on my website that sends email using SMTP and information gathered from text boxes and other inputs, etc
Everything worked fine when I tested the site locally
After launching the site, I now get a Security Exception error
Description: The
application attempted to perform an operation not allowed by the
security policy. To grant this application the required permission
please contact your system administrator or change the application's
trust level in the configuration file.
Exception Details: System.Security.SecurityException:
Request for the permission of type 'System.Net.Mail.SmtpPermission,
System, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089' failed.
You can recreate the error by visiting the site, completing the form, and hitting the "Submit" button
http://www.pennlighting.com/literature
I have already tried adding <trust level="Medium" originUrl="" /> to my web.config file, but the ISP has override turned off
On our ISP's FAQ, it states that all applications are set to Medium by default, so I don't understand why I am having this issue
I am waiting to hear back from the ISP, but their tech support's turnaround has been sub-par and I'd like to resolve this issue as soon as possible
Here is the code behind for the page. I am new to ASP.NET 2.0 and VBScript so if there is anything in my code that could be causing the problem, please let me know. Thanks!
Imports System.Net.Mail
Partial Class literature
Inherits System.Web.UI.Page
Protected Sub Submit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Submit.Click
Dim sb As New StringBuilder
sb.Append("Name: ")
sb.Append(NameBox.Text)
sb.AppendLine()
sb.Append("Email: ")
sb.Append(EmailBox.Text)
sb.AppendLine()
sb.Append("Phone: ")
sb.Append(PhoneBox.Text)
sb.AppendLine()
sb.Append("Fax: ")
sb.Append(FaxBox.Text)
sb.AppendLine()
sb.Append("Company: ")
sb.Append(CompanyBox.Text)
sb.AppendLine()
sb.Append("Address: ")
sb.Append(AddressBox.Text)
sb.AppendLine()
sb.Append("City: ")
sb.Append(CityBox.Text)
sb.AppendLine()
sb.Append("State: ")
sb.Append(StateBox.SelectedValue)
sb.AppendLine()
sb.Append("Zip Code: ")
sb.Append(ZipBox.Text)
sb.AppendLine()
sb.Append("Manufacturer: ")
sb.Append(ManufacturerBox.Text)
LitForm.ActiveViewIndex = 1
SendMail("my@email.com", sb.ToString())
End Sub
Protected Sub SendMail(ByVal from As String, ByVal body As String)
Dim Email As New MailMessage(EmailBox.Text, "my@email.com", "Literature Request", body)
Dim smtpClient As SmtpClient = New SmtpClient
smtpClient.Host = "smtp.gmail.com"
smtpClient.Port = "587"
smtpClient.EnableSsl = True
Dim credentials As New System.Net.NetworkCredential("user", "pass")
smtpClient.Credentials = credentials
smtpClient.Send(Email)
End Sub
End Class