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

Async upload triggers postback when a jpg is uploaded

6 Answers 137 Views
Upload
This is a migrated thread and some comments may be shown as answers.
David J.
Top achievements
Rank 1
David J. asked on 10 Jul 2017, 08:27 PM

Hi,

We are looking to asynchronously upload a file and temporarily store it in the AppData folder. The widget works perfectly when uploading pdf files, but for some reason it triggers a full postback when we try to upload a jpg file.

For context, here are some code snippets from the view and controller:

View

@(Html.Kendo().Upload().Name("uploadDocuments")
          .Async(a => a
              .Save("Upload", "Home")
              .AutoUpload(true)))

 

Controller

public ActionResult Upload(HttpPostedFileBase[] uploadDocuments)
        {
            foreach (var document in uploadDocuments)
            {
                var fileName = Path.GetFileName(document.FileName);
                var uploadPath = Server.MapPath("~/App_Data");
                var physicalPath = Path.Combine(uploadPath, fileName);
                document.SaveAs(physicalPath);
            }

            // Return an empty string to signify success
            return Content("");
        }

We're using Kendo for ASP .NET MVC version 2017.2.621. Any help is greatly appreciated.

Thanks!

6 Answers, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 12 Jul 2017, 11:35 AM
Hi David,

I am not sure I understand what you mean by "full postback" in the ASP.NET MVC context. In ASP.NET there are partial and full postbacks, while in ASP.NET MVC the post is to a specific controller, i.e. there is no concept of full and partial postbacks. So could you elaborate more on what exactly the difference in the behavior when uploading a .jpg file and a .pdf file consists of? In both cases the Upload action in the Home controller should be called.

Regards,
Ivan Danchev
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
David J.
Top achievements
Rank 1
answered on 12 Jul 2017, 02:49 PM

Hi Ivan,

Sorry for the confusion. What I mean by a "full postback" is that the system behaves as if it refreshed the page completely. Similar to what would happen if I pressed "Enter" on the browser's address bar. When a pdf file is uploaded, the page behaves as expected. It saves the file to AppData and the upload widget shows that the file was uploaded successfully. However, when a jpg is uploaded the file is saved to AppData normally, but the page resets completely.

If it helps, I have a simplified solution on which I was able to reproduce the issue.

Thanks again!

 

0
Ivan Danchev
Telerik team
answered on 14 Jul 2017, 11:14 AM
Hi David,

Thank you for explaining in more detail the behavior you are experiencing. I tried to reproduce it in a sample project, but to no avail: the page did not refresh regardless of uploading a pdf or a jpg file. If you have a sample project that demonstrates the issue could you please attach it, so we can take a closer look at what could be causing the different behavior at yours and at our end.

Regards,
Ivan Danchev
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
David J.
Top achievements
Rank 1
answered on 14 Jul 2017, 02:18 PM

Hi Ivan,

Thank you for your attention.The solution was too large to upload in the forum, so here's a link to download it:

...

Thanks again.

0
Ivan Danchev
Telerik team
answered on 14 Jul 2017, 02:57 PM
Hello David,

Thank you for attaching a sample project. We will review it and get back to you with new information.

On a separate note, when attaching/posting links to sample project in the forum please make sure to include only trial .dll files in it, or to remove the licensed .dll files. A licensed version of the Kendo.Mvc.dll was included in the project you linked in your last reply, which is why I edited your post and removed it.

Regards,
Ivan Danchev
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Ivan Danchev
Telerik team
answered on 17 Jul 2017, 01:37 PM
Hi David,

We checked the Upload's behavior in the project you attached, but once again we were not able to reproduce the described page refreshing. I recorded a short screencast showing how .jpg and .pdf files are uploaded without refreshing the page. Note that I added a simple input above the Upload and I type in random characters in it prior to uploading, as it is a good indication of the page being refreshed: when this happens the input loses its value. Please share any additional steps we need to follow in order to reproduce the issue.

Regards,
Ivan Danchev
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Upload
Asked by
David J.
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
David J.
Top achievements
Rank 1
Share this question
or