View Single Post
  #3 (permalink)  
Old June 5th, 2013, 01:17 PM
Tulsi Tulsi is offline
Friend of Wrox
Points: 595, Level: 8
Points: 595, Level: 8 Points: 595, Level: 8 Points: 595, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2011
Posts: 126
Thanks: 39
Thanked 2 Times in 2 Posts
Default

Hi Imar,

Thank you for directing me to this link!

Until now, I've always been confused as to how one would know what exceptions to look for. This link surely clarifies things.

After reviewing ContactForm.acx again, I noticed that there are more exceptions that may be generated in the following code in SendButton_Click() when trying to read the ContactForm.txt file:

Code:
if (string.IsNullOrEmpty(mailBody))
            {
                string fileName = Server.MapPath("~/App_Data/ContactForm.txt");
                mailBody = File.ReadAllText(fileName);
                Cache.Insert("ContactFormMailBody", mailBody, new System.Web.Caching.CacheDependency(fileName));                
            }
Should this code be wrapped in it's own try/catch block separate from the try/catch block for sending the actual email? What is the correct way to handle this type of situation?

Tulsi