Friday, May 20, 2011

The Other Side of FileUpload Control.

1. The maximum size of the fileupload control 2GB for .net 2.0 and 1GB for .net 1.0.

2 The default maximum size of the fileupload control is 4MB.

3. How to do error handling if the file size exceeds 10 MB or N MB. The steps are as follows

3.1 Create the Global.asax file which should be in the root directory of your application.

3.2 Place the below code in the Application_AuthenticateRequest event(HttpRuntimeSection)WebConfigurationManager.GetSection("system.web/httpRuntime");//Approx 100 Kb(for page content) size has been deducted because the maxRequestLength proprty is the page size, not only the file upload sizeintmaxRequestLength= (runTime.MaxRequestLength-100) *1024;//This code is used to check the request length of the page and if the request length is greater than //MaxRequestLength then retrun to the same page with extra query string value action=exception

{

(HttpWorkerRequest)provider.GetService(typeof(HttpWorkerRequest));// Check if body contains data{if (workerRequest.HasEntityBody())// get the total body lengthintrequestLength=workerRequest.GetTotalEntityBodyLength();// Get the initial bytes loaded

No comments:

Post a Comment

Search This Blog

ABOUT SIVA SHUNMUGAM

Siva Shunmugam is a software Professional works for Effindi Technologies. He loves technology because it makes the life easy and likes socializing. By beeing a professional he comes to know about how the technology is beeing handled in the real time world. Among the many technological programes he uses and embraces SQL-SERVER, ASP.NET, JQUERY simply because he uses it in his profession.

DISCLAIMER

This is a personal weblog. The opinions expressed here represent my own and not those of my employer. For accuracy and official reference refer to MSDN/ TechNet/ BOL. My employer do not endorse any tools, applications, books, or concepts mentioned on the blog. I have documented my personal experience on this blog.