Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 18th, 2008, 02:38 AM
Authorized User
 
Join Date: Dec 2008
Posts: 17
Thanks: 1
Thanked 0 Times in 0 Posts
Default

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" <mikelatzky@sbcglobal.net>
To=info@latzky.com
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.
__________________
Mike - NorCal

Last edited by MikeNorCal; December 18th, 2008 at 11:00 PM..
 
Old December 18th, 2008, 11:49 AM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

Okay, a couple of things.

1. Your TextBox1 is screwing up the postback. Put ValidateRequest="false" in the page directive to get around that problem for the time being. (After you get the page working, get rid of TextBox1 and delete the ValidateRequest="false")

2. Make sure you using a valid email address for "From".

mikelatsky@sbcglobal.net is a valid address.

Mike Latsky<mikelatsky@sbcglobal.net> is not.

As I asked you before, can you please post your mailsettings from web.config?
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
 
Old December 18th, 2008, 01:09 PM
Authorized User
 
Join Date: Dec 2008
Posts: 17
Thanks: 1
Thanked 0 Times in 0 Posts
Default

My mailsettings are:

Code:
       <mailSettings>
           <smtp from="info@latzky.com">
               <network host="smtp.latzky.com"  userName="info@latzky.com" password="mypassword" />
           </smtp>
       </mailSettings>
I'll make that postback fix to the code, although that whole debug thing still makes me crazy.....

And not sure why the From name gets screwed up. I enter mikelatzky@sbcglobal.net in the field - the rest seems to be added by code somewhere I can't figure out without debugger....
__________________
Mike - NorCal
 
Old December 18th, 2008, 03:04 PM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

Quote:
Originally Posted by MikeNorCal View Post
the rest seems to be added by code somewhere I can't figure out without debugger....
Could I ask you one favor -- could you please wrap your lines if you are going to post code? Unfortunately, I do not have a 52-inch monitor. ;-)

What do you have for your <theBeerHouse> section, namely in the <contactform> element?
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
 
Old December 18th, 2008, 04:42 PM
Authorized User
 
Join Date: Dec 2008
Posts: 17
Thanks: 1
Thanked 0 Times in 0 Posts
Default

I'll keep the code segments wrapped - to add to my problems, Firefox is doing weird things to my screen for the reply box.... I must have a "serious problem field" surrounding my place lately....

Anyway, here the (former) theBeerHouse section:
Code:
   <latzkyCom defaultConnectionStringName="LocalSqlServer">
      <contactForm mailTo="info@latzky.com"/>
      <articles pageSize="10" />
      <polls archiveIsPublic="true" votingLockByIP="false" />
      <newsletters fromEmail="newsletter@latzky.com"
 fromDisplayName="Latzky.com" />
      <forums threadsPageSize="8" hotThreadPosts="10"
  bronzePosterPosts="10" silverPosterPosts="20" goldPosterPosts="50" />
      <store sandboxMode="true" businessEmail="store@latzky.com" />
   </latzkyCom>
Wondering if this helps to figure out my problem. I've tried the ASP.NET setup, still no normal debugging.....
__________________
Mike - NorCal
 
Old December 18th, 2008, 04:44 PM
Authorized User
 
Join Date: Dec 2008
Posts: 17
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Here's the config section as well:

Code:
    <configSections>
        <section name="latzkyCom" type="MS.Latzky.LatzkyComSection, __code"/>
    </configSections>
__________________
Mike - NorCal
 
Old December 18th, 2008, 05:40 PM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

Could you please go back *now* and edit the post that is breaking the browser window for this thread, and please wrap the lines? Otherwise this thread is gonna be impossible to follow.
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
 
Old December 18th, 2008, 11:02 PM
Authorized User
 
Join Date: Dec 2008
Posts: 17
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Sincere apologies to all - I hadn't realized that was the cause of my browser wigging out; I didn't realize everyone else was getting the wide view....

I'm not sure the way I ended each line is necessarily helpful, but at least it's back to readable size.
__________________
Mike - NorCal
 
Old December 19th, 2008, 12:26 AM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

Wow, okay, that's better.

Now that the Textbox is not going to give you problems, did it give you another exception that you can examine?
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
 
Old December 19th, 2008, 11:16 AM
Authorized User
 
Join Date: Dec 2008
Posts: 17
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Unfortunately, still no joy - no error message, just the note on the normal screen that said "Sorry, problem sending your message..." in red.

Apparently, the smtp sender tries to send and gets some error. No error screen, no clear message, and the format of the data looks ok...

I've got to run out to an appointment for two hours, but will work on this when I get back....
__________________
Mike - NorCal





Similar Threads
Thread Thread Starter Forum Replies Last Post
getting formatted output in hosted powershell Mike Shepard BOOK: Professional Windows PowerShell Programming ISBN: 978-0-470-17393-0 3 October 8th, 2009 03:57 AM
Hosted Form of Component angelboy C# 2005 7 March 31st, 2008 02:36 PM
Hosted BeerHouse and sub directory gb012993 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 January 16th, 2008 01:48 AM
Events with IIS hosted remoting koraykazgan C# 1 May 1st, 2007 03:49 PM
Moving App to Hosted site dthoma128 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 13 December 19th, 2006 03:59 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.