First, I really appreciate the time and help!
Regarding the debug vs. browser view, I always hit F5 to go into a debug session - that's why I'm so confused about it not providing debugging....
Here's the Contact.aspx.cs code I'm now using:
Code:
protected void txtSubmit_Click(object sender, EventArgs e)
{
// try
// {
// send the mail
MailMessage msg = new MailMessage();
msg.IsBodyHtml = false;
msg.From = new MailAddress(txtEmail.Text, txtName.Text);
TextBox1.Text = "From="+msg.From.ToString() + "\n";
msg.To.Add(new MailAddress(Globals.Settings.ContactForm.MailTo));
TextBox1.Text += "To="+msg.To.ToString() + "\n";
if (!string.IsNullOrEmpty(Globals.Settings.ContactForm.MailCC))
msg.CC.Add(new MailAddress(Globals.Settings.ContactForm.MailCC));
msg.Subject = "Subject="+string.Format(Globals.Settings.ContactForm.MailSubject, txtSubject.Text);
TextBox1.Text += "Body="+msg.Subject.ToString() + "\n";
msg.Body = txtBody.Text;
TextBox1.Text += msg.Body.ToString();
// new SmtpClient().Send(msg);
TextBox1.Text = "From="+msg.From.ToString() + "\n" + "To="+msg.To.ToString() + "\n" +
"Subject="+msg.Subject.ToString() + "\n" + "Body="+msg.Body.ToString();
// show a confirmation message, and reset the fields
lblFeedbackOK.Visible = true;
lblFeedbackKO.Visible = false;
txtName.Text = "";
txtEmail.Text = "";
txtSubject.Text = "";
txtBody.Text = "";
// }
// catch (Exception)
// {
// lblFeedbackOK.Visible = false;
// lblFeedbackKO.Visible = true;
// }
}
I created a TextBox1 field on the Contact page for it to display as I go. I commented out the try/catch so I'd get something when it bombed.
Here's the error info from the page when I execute:
Code:
A potentially dangerous Request.Form value was detected from the client
(ctl00$MainContent$TextBox1="... Latzky" <mikelatzky@sbcgloba...").
body {font-family:"Verdana";font-weight:normal;font-size:
.7em;color:black;} p {font-family:"Verdana";font-
weight:normal;color:black;margin-top: -5px} b {font-
family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
H2 { font-family:"Verdana";font-
weight:normal;font-size:14pt;color:maroon } pre {font-
family:"Lucida Console";font-size: .9em} .marker {font-weight: bold;
color: black;text-decoration: none;} .version {color: gray;}
.error {margin-bottom: 10px;} .expandable {
text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }
Server Error in '/TBH_Web' Application.
A potentially dangerous Request.Form value was detected from the
client (ctl00$MainContent$TextBox1="... Latzky"
<mikelatzky@sbcgloba...").
Description: Request Validation has detected a potentially dangerous client input
value, and processing of the request has been aborted. This value may indicate an
attempt to compromise the security of your application, such as a cross-site scripting
attack. You can disable request validation by setting validateRequest=false in the Page
directive or in the configuration section. However, it is strongly recommended that your
application explicitly check all inputs in this case.
Exception Details: System.Web.HttpRequestValidationException: A potentially
dangerous Request.Form value was detected from the client
(ctl00$MainContent$TextBox1="... Latzky" <mikelatzky@sbcgloba...").
Source Error:
[No relevant source lines]
Source File: c:\Users\Mike\AppData\Local\Temp\Temporary ASP.NET Files\tbh_web
\ddaa1cd2\ae88a0da\App_Web_r-yaiwtw.18.cs Line: 0
Stack Trace:
[HttpRequestValidationException (0x80004005): A potentially dangerous
Request.Form value was detected from the client (ctl00$MainContent$TextBox1=
"... Latzky" <mikelatzky@sbcgloba...").]
System.Web.HttpRequest.ValidateString(String s, String valueName, String
collectionName) +3308050
System.Web.HttpRequest.ValidateNameValueCollection(NameValueCollection nvc,
String collectionName) +108 System.Web.HttpRequest.get_Form() +119
System.Web.HttpRequest.get_HasForm() +3309998
System.Web.UI.Page.GetCollectionBasedOnMethod(Boolean dontReturnNull) +45
System.Web.UI.Page.DeterminePostBackMode() +65
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,
Boolean includeStagesAfterAsyncPoint) +7350
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint,
Boolean includeStagesAfterAsyncPoint) +213
System.Web.UI.Page.ProcessRequest() +86
System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +18
System.Web.UI.Page.ProcessRequest(HttpContext context) +49
ASP.contact_aspx.ProcessRequest(HttpContext context) in c:\Users\Mike\AppData
\Local\Temp\Temporary ASP.NET Files\tbh_web\ddaa1cd2\ae88a0da\App_Web_r-
yaiwtw.18.cs:0
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep
.Execute() +358 System.Web.HttpApplication.ExecuteStep(IExecutionStep step,
Boolean& completedSynchronously) +64
Version Information: Microsoft .NET Framework Version:2.0.50727.1434;
ASP.NET Version:2.0.50727.1434
The info I seem to get for each "field" is:
From="Mike Latzky" <
[email protected]>
[email protected]
Subject=Subject=Mail from Latzky.com: Test Message
Body=ddqdqdqd
The Sender field appears to be null/empty, not sure if it should be.... This is all from my local Vista PC which has no smtp server running on it, so getting a message send failure makes sense. On the hosted site, the Error.aspx page takes over of course, so I don't get valid info there. I could of course modify web.config to see the result, and should just so I know what is really happening up there.
The inability to debug is a serious problem, and the uncertainty of what needs to e in each of the message fields to make a successful email go is also a problem for me.