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

sometimes IEnumerable<HttpPostedFileBase> is null

2 Answers 94 Views
Upload
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Tomas
Top achievements
Rank 1
Tomas asked on 17 Jul 2012, 11:38 AM
I am using MVC Telerik Upload and  while testing it I noticed that sometimes clientUpload is Null. I can't understand why some files are not uploaded though UploadFile  action is called. I have tried numerous time to reproduce this on Dev machine without any luck but some users on Prod server reproduce this bug. Maybe someone could point me where could be the problem?

The code is below (version 2012.2.607.340)

    @using (Html.BeginForm())
    {

  @(Html.Telerik().Upload()
           .Name("clientUpload")
           .Async(async => async
                               .Save("UploadFile", "File")
                               .Remove("Remove", "File")
                               .AutoUpload(false)
           )
           .ShowFileList(false)
           .Multiple(true)
           .ClientEvents(events => events
                                       .OnUpload("onUpload")



           )


          )
}

 function onUpload(e) {


        e.data = serializeForm();
}

function serializeForm() {
        var data = $("form").serializeArray();
        var formData = {};
        for (var i = 0; i < data.length; i++) {
            formData[data[i].name] = data[i].value;
        }

        return formData;
    }



        [HttpPost]        
        public ActionResult UploadFile(IEnumerable<HttpPostedFileBase> clientUpload, [OptionModelBinder]IOptionModel formData)
        {
           //sometimes clientUpload is null
        }

2 Answers, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 26 Jul 2012, 12:20 PM
Hello,

Such problems are difficult to debug. Your best bet is to log the requests and try to spot a pattern in the failures. 

There are several approaches to logging. You can write your own HTTP module or use IIS failed request logging, to name just two of many.

I hope this helps.

Greetings,
Tsvetomir Tsonev
the Telerik team
Check out the successor of Telerik MVC Extensions - Kendo UI for ASP.NET MVC - and deem it for new ASP.NET MVC development.
0
Tomas
Top achievements
Rank 1
answered on 26 Jul 2012, 02:13 PM
Thank you, I will try your recommended solutions. What I found so far is that ContentLength and TotalBytes do not match in request object. So it means the POST(upload) was interrupted but then why upload event in MVC app is fired? Also I found that this happens on Firefox.

Cache-Control=no-cache
Connection=keep-alive
Pragma=no-cache
Content-Length=4318072 (4.12 MB)
Content-Type=multipart/form-data; boundary=---------------------------265001916915724
Accept=text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding=gzip, deflate
Accept-Language=tr-tr,tr;q=0.8,en-us;q=0.5,en;q=0.3
Cookie=ASP.NET_SessionId=qoepkjemce41dervfpctm5xf; __utma=25844526.387102337.1343310072.1343310072.1343310072.1; __utmb=25844526.1.10.1343310072; __utmc=25844526; __utmz=25844526.1343310072.1.1.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=mdi%20pdf%20converter
User-Agent=Mozilla/5.0 (Windows NT 5.1; rv:13.0) Gecko/20100101 Firefox/13.0.1
File=Zero elements found
Form=Zero elements found
AnonymousID=null
ApplicationPath=/
AppRelativeCurrentExecutionFilePath=~/File/UploadFile
ContentLength=4318072
ContentType=multipart/form-data; boundary=---------------------------265001916915724
CurrentExecutionFilePath=/File/UploadFile
CurrentExecutionFilePathExtension=
FilePath=/File/UploadFile
HttpMethod=POST
Path=/File/UploadFile
PathInfo=
RawUrl=/File/UploadFile
RequestType=POST
TotalBytes=982242
UserAgent=Mozilla/5.0 (Windows NT 5.1; rv:13.0) Gecko/20100101 Firefox/13.0.1
UserHostAddress=78.187.28.43
UserHostName=78.187.28.43

Tags
Upload
Asked by
Tomas
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Tomas
Top achievements
Rank 1
Share this question
or