473,499 Members | 1,595 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1134
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
2066
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
5154
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
1955
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
2195
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...
0
7131
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7007
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6894
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7388
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5470
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4919
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3091
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
297
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.