得到错误:-system.web.httpcontext.current.request.files'引发了类型'system.outofmemoryexception的异常 [英] Getting error:-system.web.httpcontext.current.request.files' threw an exception of type 'system.outofmemoryexception

查看:109
本文介绍了得到错误:-system.web.httpcontext.current.request.files'引发了类型'system.outofmemoryexception的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我们上传多个上传文件时,上传的文件大小很大。然后我们得到错误: - System.Web.HttpContext.Current.Request.Files'引发了类型'System.OutOfMemoryException的异常。在处理程序文件请求HttpFileCollection files = context.Request.Files中。



我尝试过:



When we are uploading multiple upload files are large file size uploaded. Then we are getting error:- System.Web.HttpContext.Current.Request.Files' threw an exception of type 'System.OutOfMemoryException. In the handler file request " HttpFileCollection files = context.Request.Files".

What I have tried:

ajaxFileUploadFile: function (e) {
            try {
                debugger;
                var _data = new Array();
                _data.push({ 'name': 'action', 'value': 'uploadFile' });
                _data.push({ 'name': 'folderpath', 'value': $("#hdnfolderpath").val() });
                _data.push({ 'name': 'AssetValue', 'value': 'IM' });

                $(e).SingleFileUploader({
                    action: 'Handler/hnUploadfile.ashx',
                    fileinputid: "uploadfile1",
                    senddata: _data,
                    queueSizeLimit: 50,
                    fileSizeLimit: '900MB',
                    onSubmit: function (filename) { },
                    onSelect: function (file) {
                        $("#btnImportToDataBase").attr('disabled', true);
                        $("#btnValidateData").attr('disabled', true);
                        $("#btnUpload").attr('disabled', true);

                    },
                    onComplete: function (filename, response) {

                        if (response == 1) {
                            $("#spnChooseFile").html("Choose a file…");
                            $("#divAlertFile1").html("Error in uploading file. Sorry for inconvience. Please try again.");
                            $("#divAlertFile1").removeClass();
                            $('#uploadmediafile').attr('disabled', false);
                            $("#uploadfile1").attr('disabled', false);
                            $("#UploadLJpg").attr('disabled', false);
                            $("#divAlertFile1").addClass("alertMessage alert-danger");
                            $("#divAlertFile1").show();
                            $("#divfileuploader1").addClass("progress-bar-danger");
                            ProgressBar1.running = false;
                            $("#divfileuploader1").css('width', '100%').attr('aria-valuenow', 100);
                            $("#progressBar1").delay(2000).hide(0);

                            $("#lblfileUploadFlag").html("");
                            $("#txtfile").val("");

                            setTimeout(function () {
                                $("#divAlertFile1").hide();
                                $("#divfileuploader1").removeClass("progress-bar-danger");
                                $("#divfileuploader1").addClass("progress-bar");

                                ProgressBar1.running = true;
                                UploadFile1.initlizeFileControl();

                                $("#uploadfile1").unbind();
                                $("#btnUploadFile1").unbind();

                                $("#uploadfile1").change(function () {
                                    UploadFirstCall = false;
                                    UploadFile1.ajaxFileUploadFile("#btnUploadFile1");
                                    UploadFile1.imageChangeFile(this);
                                });

                            }, 5000);
                        }
                        else if (response == 2) {

                            $("#spnChooseFile").html("Choose a file…");
                            if (page_count == 1) {
                                $("#divAlertFile1").html("Please upload pdf of " + page_count + " page.");
                            }
                            else {
                                $("#divAlertFile1").html("Please upload pdf of " + page_count + " pages.");
                            }
                            $("#divAlertFile1").removeClass();
                            $("#divAlertFile1").addClass("alertMessage alert-danger");
                            $("#divAlertFile1").show();
                            $('#uploadmediafile').attr('disabled', false);
                            $("#uploadfile1").attr('disabled', false);
                            $("#UploadLJpg").attr('disabled', false);
                            $("#divfileuploader1").addClass("progress-bar-danger");
                            ProgressBar1.running = false;
                            $("#lblfileUploadFlag").html("");
                            $("#txtfile").val("");
                            $("#divfileuploader1").css('width', '100%').attr('aria-valuenow', 100);
                            $("#progressBar1").delay(2000).hide(0);

                            setTimeout(function () {
                                $("#divAlertFile1").hide();
                                $("#divfileuploader1").removeClass("progress-bar-danger");
                                $("#divfileuploader1").addClass("progress-bar");

                                ProgressBar1.running = true;
                                UploadFile1.initlizeFileControl();

                                $("#uploadfile1").unbind();
                                $("#btnUploadFile1").unbind();

                                $("#uploadfile1").change(function () {
                                    UploadFirstCall = false;
                                    UploadFile1.ajaxFileUploadFile("#btnUploadFile1");
                                    UploadFile1.imageChangeFile(this);
                                });

                            }, 4000);

                        }
                        else {
                            OnCompletegetfiledetails(filename, JSON.stringify(response), true)
                            $("#spnChooseFile").html("Choose a file…");
                            $("#divfileuploader1").addClass("progress-bar-success");
                            $('#uploadmediafile').attr('disabled', false);
                            $("#uploadfile1").attr('disabled', false);
                            $("#UploadLJpg").attr('disabled', false);
                            ProgressBar1.running = false;
                            $("#divfileuploader1").css('width', '100%').attr('aria-valuenow', 100);
                            $("#progressBar1").delay(2000).hide(0);

                            var data = jQuery.parseJSON(JSON.stringify(response));
                            setTimeout(function () {
                                $("#divAlertFile1").removeClass();
                                $("#divAlertFile1").html(data.assetfiles + ' is ' + "Uploaded");


                                //                                $("#divAlertFile1").html(data.uploaded_file_name + ' is ' + "Uploaded");
                                $("#divAlertFile1").addClass("alertMessage fileuploadsuccess");
                                $("#divAlertFile1").show();

                                $("#divfileuploader1").removeClass("progress-bar-success");
                                $("#divfileuploader1").addClass("progress-bar");

                                ProgressBar1.running = true;
                                UploadFile1.initlizeFileControl();

                                $("#uploadfile1").unbind();
                                $("#btnUploadFile1").unbind();

                                $("#uploadfile1").change(function () {
                                    UploadFirstCall = false;
                                    UploadFile1.ajaxFileUploadFile("#btnUploadFile1");
                                    UploadFile1.imageChangeFile(this);
                                });

                            }, 2000);
                        }

                    }
                });
            }
            catch (Error) {
            }
        }
    }


C# handler code:-


 HttpFileCollection files = context.Request.Files;
                    for (int i = 0; i < files.Count; i++)
                    {
                      //  Thread.Sleep(3000);
                        HttpPostedFile fileToUpload = files[i];
}

推荐答案

(#hdnfolderpath)。val()});
_data.push({'name':'AssetValue','value':'IM'});
("#hdnfolderpath").val() }); _data.push({ 'name': 'AssetValue', 'value': 'IM' });


(e).SingleFileUploader({
action :'Handler / hnUploadfile.ashx',
fileinputid:uploadfile1,
senddata:_data,
queueSizeLimit:50,
fileSizeLimit:'900MB',
onSubmit :function(filename){},
onSelect:function(file){
(e).SingleFileUploader({ action: 'Handler/hnUploadfile.ashx', fileinputid: "uploadfile1", senddata: _data, queueSizeLimit: 50, fileSizeLimit: '900MB', onSubmit: function (filename) { }, onSelect: function (file) {


(#btnImportToDataBase)。attr('disabled',true);
("#btnImportToDataBase").attr('disabled', true);


这篇关于得到错误:-system.web.httpcontext.current.request.files'引发了类型'system.outofmemoryexception的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆