Solved

Sharepoint Attachment Exceed Size C#

Posted on 2009-05-17
5
651 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 32

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 32

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 32

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Pimping Sharepoint 2007 without Server-Side Code Part 1 One of my biggest frustrations with Sharepoint 2007 in the corporate world is that while good-intentioned managers lock down the more interesting capabilities of Sharepoint programming in…
A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

737 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