Solved

Sharepoint Attachment Exceed Size C#

Posted on 2009-05-17
5
647 Views
Last Modified: 2012-05-07
Hi!
I am developing sharepoint webparts and would like to ask a question.

I have an upload control in C# and i have set the file limit in sharepoint adminsitration as 50MB.
When i attempt to upload a 60MB file, the sharepoint site will throw an exception.

Is there any where or idea how i can catch this exception and redirect to our custom error page or stop the upload and inform the user that the file is too large?
0
Comment
Question by:darenceang
  • 3
  • 2
5 Comments
 
LVL 31

Expert Comment

by:Jamie McAllister MVP
ID: 24410007
If you want to monitor the size of the file before upload it can be done with Javascript but it's not pretty;

http://www.kavoir.com/2009/01/check-for-file-size-with-javascript-before-uploading.html
0
 
LVL 4

Author Comment

by:darenceang
ID: 24410367
am unable to run activex on my environment here.
Guess they think its a bigger risk.
Thus, my project dont allow it.

Any more other ways i can do a check without uploading the whole thing over?

I;ve heard someone saying about what packet size headers etc...
0
 
LVL 31

Expert Comment

by:Jamie McAllister MVP
ID: 24410437
I've seen stuff related to packet size headers in PHP, but that doesn't help here! www.phpeasystep.com/phptu/3.html

I guess you're back to capturing the exception and displaying a custom error screen.

Easy way to display an error screen with a custom message is to use;

SPUtility.TransferToErrorPage(message)
0
 
LVL 4

Accepted Solution

by:
darenceang earned 0 total points
ID: 24410515
But doing a try catch can only catch the exception after the WHOLE file is posted upwards?
Is that not?

Sorry... noob
0
 
LVL 31

Expert Comment

by:Jamie McAllister MVP
ID: 24410585
That's right, but alas discounting the javascript/activeX route means we have no way (I'm aware of) of stopping an inappropriate file upload before it happens.

I had a look around for a JQuery method to do this, but it seems to come back to PHP or stuff like this;

http://www.pixeline.be/experiments/jqUploader/

But I'm guessing you can't use that.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SharePoint Foundation 2013 Search 11 36
c# string handling 1 26
Licensing Sharepoint 2016 for developers 11 28
Coding C# in Linux 8 21
The vision: A MegaMenu for a SharePoint portal home page The mission: Make it easy to maintain. Allow rich content and sub headers as well as standard links. Factor in frequent changes without involving developers or a lengthy Dev/Test/Prod rel…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now