469,926 Members | 1,526 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,926 developers. It's quick & easy.

File Upload (Email) and catching the Upload size of 4mb

I am confussed on what the heck is going on ?! I have an HTML INPUT
File Box on an Email Piece of an application. I know that File Size is
set to 4MB in the WebConfig File and that is fine, but I have a couple
problems that include the magical 4mb number.

1. My problem is that when my file is over the 4 mb limit. If the 4 MB
limit is met then the code on the button I use doesn't even fire (as I
have code to check the file length before it is attached to the email
maessage). How or what can be done to capture the error/file size?

I do have code in my button to capture it, but it never runs,

Dim AttachmentLength As Integer = MyFile.PostedFile.ContentLength

If AttachmentLength < 4000000 Then
Response.Write("NOT too big")
Response.Write("TOO big")
End If

2. If my File is between 1.6/1.7MB and 4MB, it is okay until the part
where the email is built and sent. It errors out at:
"Catch ehttp As System.Web.HttpException"
and replies "***ERRORS OUT HERE !! ***".

Why between the 1.6mb and 4mb mark does it bomb out at the emailing
piece ?!

Msg.From = "BL**@BLAH.com"
Msg.To = "BL**@BLAH.com"
Msg.Subject = SubjectTextBox.Text
Msg.Body = MessageTextBox.Text
Msg.BodyFormat = MailFormat.Text
SmtpMail.SmtpServer = .....
"<script language='javascript'>alert(successful')</script>")
Catch ehttp As System.Web.HttpException
"<script language='javascript'>alert('***ERRORS OUT HERE !!
End Try
Catch ee As IndexOutOfRangeException
"<script language='javascript'>alert('UNKNOWN ERROR ***')
End Try

Jul 21 '05 #1
1 2017
This is a follow up to my previous message as I am having the same
inconsistant issues with the Attachment Size and what is set where

I have made sure all 4 settings are all the same (4 MB) either by
defualt or by Changing them.
- Web.Config
- Machine.Config
- Code Behind

- In IIS, I changed the default "Limit Message Size to (KB)" from 2048
to 4096.

- In the Web.Config, I have added:
"<httpRuntime maxRequestLength="4096"

- In Machine.Config I have verified that the settings are as follows
(by defualt):
"<httpRuntime executionTimeout="90"

- In Code Behind, I have the following code to "Weed out" and give an
error to the user per the file size:
"If AttachmentLength > 4000000 Then
Page.RegisterClientScriptBlock("Fill465", "<script
language='javascript'>alert('ERROR - File too Large.')</script>")
End If"

The problem is that Attachments that are est. 2992KB (2.9MB) are okay
and send. The Files that are 3065KB (3.0MB) or larger don't send nor
do anything error related/generate per the IF Statement in th Code
behind. Nothing !! No JAVAScript Error per Code Behind, No Error from
Server, NOTHING !! WTF ?!?!?!?!?!?!?!?!?!
Attachment = 2992kb = Okay/Sent Fine (Good !!)
Attachment = 3065kb = NOTHING HAPPENS (BAD !!)

Why in the world is this happening ?!?!

As a TEST left the IIS Settings the same , Web.Config and
Machine.Config all the same but changed the Code Behind to give the
JAVAScript Error if over 1 MB (>1000000) and the results are confusing
Here is what happened with some more attachments:
Attachment <= 929kb = Okay/Sent Fine (Good !!)
Attachment >= 1022kb and <=3065kb = JavaScript Error is generated
(Good !!)
Attachment >= 4259kb = NOTHING HAPPENS (BAD !!)
1. Does anyone have any type of explination or things I can try?
2. What order is the size checked (as someone mentioned that the
Web.Config over rides the Machine.Config File) ?
3. In the Machine.Config, the setting is set to 4096:
"maxRequestLength="4096"", but the explination says 3000kb: "
maxBatchGeneratedFileSize="max combined size (in KB) of the generated
source files per batched compilation" // Default: 3000KB"?
4. How can I tell the whole email size and not just the Attachement?

Thanks !!!
Jul 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Jefferis NoSpamme | last post: by
4 posts views Thread by UJ | last post: by
24 posts views Thread by owz2008 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.