View Single Post
  #4 (permalink)  
Old June 6th, 2013, 04:11 AM
Imar's Avatar
Imar Imar is offline
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

Hi Tulsi,

It depends ;-)

In my opinion, the fact that the mail body file can't be found or read is a software or configuration error that won't go away automatically. This means there's no point in showing the user a message like "Ooops, something went wrong; please try again:.

Instead, you want to be notified of this error using the global error handler in Global.asax (or better yet, with ELMAH). The easiest thing to do is not handle this exception in the contact control, but rely on custom errors. This way, the user gets the generic Error 500 page and the error message is logged.

In general, you should catch exceptions that you know how to handle, and let the others bubble up as unhandled exceptions and log them at the global level.

Hope this helps,

Imar Spaanjaars
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
Tulsi (June 6th, 2013)