I'm still trying to teach myself c# and web programming, and I'm stuck on trying to figure out how to get this exception to work.
I have a web form that allows the user to select an attachment to include with the email. I want to put a limit on the file size to 10mb. When the user has entered in the information and selected the attachment, the user then clicks on submit and the email is created and sent out. What I would like to do in theory is if the attachment is too large, notify the user before sending the email without the attachment so he or she can make arrangements to get the attachment to the person in a different way. What I have below doesn't work. I stepped through the code and it goes to the catch statement, but I guess I just don't understand how to use the response.write correctly, as it just continues on with the rest of the code with no message.
if (filename.PostedFile.ContentLength > 18000)
throw new Exception();
Any help is appreciated. Thanks