This is a migrated thread and some comments may be shown as answers.

DivideByZeroException

11 Answers 103 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
John Landeborg
Top achievements
Rank 1
John Landeborg asked on 28 Dec 2010, 01:53 PM
RadUpload Ajax callback error
...
RadUploadContext.GetProgressData()

The error is intermittent and occur before progressbar is visible.

It's a customer’s production server that I have no access to, so I have no server logs available etc. It look likes the response time is slow. Compare with other installations the time between I submit a file and to the progress is displayed is longer.

Is it possible that UploadedFile property ContentLength return 0?

if (RadUpload.UploadedFiles.Count > 0)
{
  uploadedFile = RadUpload.UploadedFiles[0];
  totalSize = uploadedFile.ContentLength;
}

do
{
                        bytesRead = reader.Read(buffer, 0, readChunkSize);
                        ms.Write(buffer, 0, bytesRead);
                        processedSize += bytesRead;
                        percent = (int)((processedSize / totalSize) * 100);
                        progress["SecondaryTotal"] = total.ToString();
                        progress["SecondaryValue"] = percent.ToString();
                        progress["SecondaryPercent"] = percent.ToString();
                        progress["CurrentOperationText"] = fileReadingMsg;
} while (bytesRead != 0);


Any suggestions?

11 Answers, 1 is accepted

Sort by
0
Genady Sergeev
Telerik team
answered on 03 Jan 2011, 12:43 PM
Hi John Landeborg,

It is unlikely that an uploaded fie will arrive at the server with ContentLentgth of zero, at least we haven't heard of similar reports from other clients. Is the error breaking the progress functionality? If no, you can suppress it, however, I need the exact error in order to provide you with the needed script. Apart from this, indeed the time between pressing the submit button and when the area is actually shown, is determined by the time it takes for the request to the progress area handler to return response. I am wondering whether you are not facing a timeout issue. Can you please paste a the detailed error here? A screenshot will also be of help.



Kind regards,
Genady Sergeev
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
John Landeborg
Top achievements
Rank 1
answered on 03 Jan 2011, 02:38 PM

Thanks!

Because the error arise so rarely I have not had opportunity to catch a error message.. yet.. But one error report send to me (by Skype) is here:

RadUpload Ajax callback error. Source url returned invalid content: System.DivideByZeroException: Det gjordes ett försök att dividera med noll. vid System.Decimal.FCallDivide(Decimal& d1, Decimal& d2) vid Telerik.Web.UI.RadUploadContext.PopulateProgressData(RadUploadProgressData progressData) vid Telerik.W

Skype truncated the message….

The other time was by a webuser that did a print + scan + mail thing, so it looks terrible. But her it is…

And yes. The error breaks the upload and no progress is shown. Should I realy catch and ignore the error?

0
Genady Sergeev
Telerik team
answered on 06 Jan 2011, 01:15 PM
Hello John Landeborg,

This is really strange problem. I suggest that you bullet proof your code against Division By Zero exception, for example you can check whether totalSize is bigger than zero. To be honest I can't think of a possible reason for file size being zero, perhaps it is a very rare issue that we haven't faced yet. In general I think that bullet proofing your code would do the job.

Regards,
Genady Sergeev
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
John Landeborg
Top achievements
Rank 1
answered on 26 Jan 2011, 10:06 AM
I have correct the code and check if size is zero, so the error should not occur and the user have to try to upload the file again. But the file is not zero, so the mystery remains! I have been able since last to read event - and iis-loggfiles. No conclusive result. The best guess yet is some kind of timeout due bad response time. Only 1 error report since last and this time I received a nice screenshot.
0
Genady Sergeev
Telerik team
answered on 31 Jan 2011, 05:40 PM
Hello John Landeborg,

I was thinking about increasing the time before a request would time out. Please take a look at this MSDN topic, which presents the httpRuntime element in web.config. You can use its executionTimeout property in order to set timeout timespan for a web request.


Kind regards,
Genady Sergeev
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Lakshmi Satish Maddela
Top achievements
Rank 1
answered on 23 Sep 2011, 05:59 AM
Hi,
    I am also facing similar type of error, but could not get a resolution to the issue. Please let me know in case of any suggestions.I am attaching the screenshot here.
0
John Landeborg
Top achievements
Rank 1
answered on 23 Sep 2011, 04:01 PM

Check uploadeFile.ContentLengt is >0 before divide. But is it rely 0 no file is uploaded… Probably a timeout issue, so check web.config settings like something like:

<httpRuntime maxRequestLength="2000000" executionTimeout="600"/>

0
Douglas R.
Top achievements
Rank 1
answered on 10 Oct 2012, 05:33 PM
An uploaded file will have a context length of zero when the user types in the name of a file that does not exist.  For example,

d:\context length zero.jpg
0
Genady Sergeev
Telerik team
answered on 15 Oct 2012, 01:42 PM
Hi Douglas,

I've tried to reproduce the problem on our online demos, however, no avail. The FileDialong did correctly moan that such file does not exist. However, we might be missing something obvious. Could you please record a short video demonstrating how to reproduce the problem?

All the best,
Genady Sergeev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Douglas R.
Top achievements
Rank 1
answered on 15 Oct 2012, 02:15 PM
Version 2.4.6 (RadUpload.Net2.DLL) doesn't force the user to use the file open dialog -- they can type a file name into the input box.
0
Genady Sergeev
Telerik team
answered on 18 Oct 2012, 10:05 AM
Hi John,

It seems that you are using the classic controls, which are no longer supported and are likely to have issues, especially with the modern browsers. I suggest that you update to the ASP.NET Ajax controls as a resolution for the problem.

Greetings,
Genady Sergeev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Upload (Obsolete)
Asked by
John Landeborg
Top achievements
Rank 1
Answers by
Genady Sergeev
Telerik team
John Landeborg
Top achievements
Rank 1
Lakshmi Satish Maddela
Top achievements
Rank 1
Douglas R.
Top achievements
Rank 1
Share this question
or