473,289 Members | 1,848 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,289 software developers and data experts.

How to trap errors on file uploads?

I'm using VS 2003.

I'm uplading a file using Input Type='File' .PostedFile. etc.
How does one trap the error when the file is larger than the 4 Meg
default? Try/Catch doesn't work. I get the "This page cannot be
displayed screen". I also tried adding a Page Error handler which
didn't work. I want to tell the user that the file size is too large.

Thanks,
Sal

May 17 '06 #1
3 1128
I would look at the PostedFile.ContentLength property using an If statement.
For Example, see if something like the following works (I haven't tested it,
but I would expect it to work):
If myfile.PostedFile.ContentLength<=4194304 Then

End If
I think the reason for your problem has something to do with the order that
the operations are performed in, but since I am not an expert on that and I
haven't seen your code, I can't say for sure. Good Luck!
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"SalP" <sa*************@yahoo.com> wrote in message
news:11**********************@y43g2000cwc.googlegr oups.com...
I'm using VS 2003.

I'm uplading a file using Input Type='File' .PostedFile. etc.
How does one trap the error when the file is larger than the 4 Meg
default? Try/Catch doesn't work. I get the "This page cannot be
displayed screen". I also tried adding a Page Error handler which
didn't work. I want to tell the user that the file size is too large.

Thanks,
Sal

May 17 '06 #2
It doesn't get to the C# code-behind file. It displays "This page
cannot be displayed" and ignores the Try/Catch block.

Sal

Nathan Sokalski wrote:
I would look at the PostedFile.ContentLength property using an If statement.
For Example, see if something like the following works (I haven't tested it,
but I would expect it to work):
If myfile.PostedFile.ContentLength<=4194304 Then

End If
I think the reason for your problem has something to do with the order that
the operations are performed in, but since I am not an expert on that and I
haven't seen your code, I can't say for sure. Good Luck!
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"SalP" <sa*************@yahoo.com> wrote in message
news:11**********************@y43g2000cwc.googlegr oups.com...
I'm using VS 2003.

I'm uplading a file using Input Type='File' .PostedFile. etc.
How does one trap the error when the file is larger than the 4 Meg
default? Try/Catch doesn't work. I get the "This page cannot be
displayed screen". I also tried adding a Page Error handler which
didn't work. I want to tell the user that the file size is too large.

Thanks,
Sal


May 17 '06 #3

the http protocol does not support stopping an upload and returnning an
error to the browser. when asp.net detects the upload is too larger (by
counting how many bytes its received), it kills the connection to the
browser to stops the upload.

so while you can catch the error on the server and log it, you can not send
any message back to the browser, because the request failed (from the
browsers point of view) and the browser prints the error message of its
choice.

-- bruce (sqlwork.com)
"SalP" <sa*************@yahoo.com> wrote in message
news:11**********************@y43g2000cwc.googlegr oups.com...
I'm using VS 2003.

I'm uplading a file using Input Type='File' .PostedFile. etc.
How does one trap the error when the file is larger than the 4 Meg
default? Try/Catch doesn't work. I get the "This page cannot be
displayed screen". I also tried adding a Page Error handler which
didn't work. I want to tell the user that the file size is too large.

Thanks,
Sal

May 17 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Kikoz | last post by:
Hi all. I assume that if the user uploads a file from aspx page IIS will put all future requests to the same page from other users in a line and all of them will be waiting until this upload...
4
by: yehaimanish | last post by:
I am developing the project management system. Each Project: 1. Title, description ... , stored in mysql database 2. Upto ten files (initial description), (name in db, file in file system) 3....
1
by: Massimiliano Campagnoli | last post by:
Hi All, I know that db2 V7.2 is no more supported and nor OS/2 is supported anymore but I wonder if someone here can give me some help on this. Platform: DB2 V7.2 FixPak 14 OS: OS/2 (actually...
6
by: Emmanuel Petit | last post by:
First of all I am rather new into PHP. I use php 5 and I am putting together a web site for a local association I belong too. Most of the site is okay, except for this problem : I need to be...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.