Solved

Sharepoint Attachment Exceed Size C#

Posted on 2009-05-17
5
652 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
When using a search centre, I'm going to show you how to configure Sharepoint's search to only return results from the current site collection. Very useful when using Office 365 with multiple site collections.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

691 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