By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,263 Members | 2,640 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,263 IT Pros & Developers. It's quick & easy.

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

P: n/a
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")
else
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 ?!

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

PLEASE HELP !!
bthomas71chevy_AT_excite_DOT_com
Jul 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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.
- IIS
- 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"
useFullyQualifiedRedirectUrl="true"
executionTimeout="180"/>"

- In Machine.Config I have verified that the settings are as follows
(by defualt):
"<httpRuntime executionTimeout="90"
maxRequestLength="4096"
useFullyQualifiedRedirectUrl="false"
minFreeThreads="8"
minLocalRequestFreeThreads="4"
appRequestQueueLimit="100"
enableVersionHeader="true"/>

- 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>")
Else
...
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 ?!?!?!?!?!?!?!?!?!
Example:
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.