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

Script5: Access is denied intermittent error on Kendo file upload

3 Answers 99 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Shawn Taylor
Top achievements
Rank 1
Shawn Taylor asked on 04 Jul 2013, 02:35 AM
I am using the Kendo UI Upload control with the Knockout-Kendo.js project's binders.  I have a file upload control on my form and am seeking to upload the file through the ajax callback provided by the Knockout-Kendo.js api.  Most of the time, the upload goes through successfully, but every once in a while, so far only on IE, there's an issue and I get a javascript error saying "SCRIPT5: Access is denied."   I've read that IE9 has security rules that can cause this error in certain situations, but I do not understand well enough how the kendo ui control works (or how the knockout-kendo library works) to understand what I might need to change to prevent the error.  Any ideas will be very much appreciated!

Here is a simplified version of my code:
In the view:
<input name="fileUpload" type="file" id="fileUpload" data-bind="kendoUpload: $root.fileUploadSettings()" />

In the javascript viewmodel:
var fileCategory = "myCategory";
 
fileUploadSettings = function () {
        var kendoSettings = {
            multiple: false,
            enabled: true,
            async: { saveUrl: "../Entity/AddFiles" },
            success: function (e) { _uploadFileSuccess(e, fileCategory); },
            error: function (e) { _uploadFileError(e, fileCategory); },
            select: function (e) { _uploadFile(e, fileCategory); },
            localization: { select: "Upload File" },
        };
In the MVC controller: 
[HttpPost]
public ActionResult AddFiles(File data, System.Web.HttpPostedFileBase fileUpload)
{
    try
    {
        File file = FileUIService.AddFile(data, fileUpload);
        FileView rfv = new FileView()
        {
            Id = file.Id,
            Name = fileUpload.FileName.Substring(fileUpload.FileName.LastIndexOf('\\') + 1)
        };
 
        return Json(rfv, "text/plain");
    }
    catch (Exception ex)
    {
        return Json(ex.Message, "text/plain");
    }
}

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 05 Jul 2013, 11:37 AM
Hello,

I posted my reply in the support ticket on the same topic. For convenience I am pasting it below:

This error is thrown in Internet Explorer when opening the dialog by triggering the click event via code instead of clicking on the button. This is a security feature of the browser and the same error can be reproduced with an input type file. How is the dialog opened in your scenario?

Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Shawn Taylor
Top achievements
Rank 1
answered on 08 Jul 2013, 12:09 PM
Yes, I do see posts online about this error being triggered when a click event on an upload control is triggered indirectly through javascript.  Unfortunately, I do not see how that may apply in this situation.  My upload is triggered by the user clicking on a control on the page.  As far as I know, that control is the input control that I included in the code section of my original post.  Unless knockout-kendo library or the kendo ui library is manipulating the DOM in a way I would not expect, the click event is being directly triggered by the user.  I've looked through the knockout-kendo library, and it appears that the code there is concerned only with the binding between the viewmodel and the kendo-ui widget, not with adding or removing anything from the DOM.  I am not familiar with the internals of the kendo-ui widget itself, but I assume that you would be aware if that were causing the click even to be indirectly triggered.  

I should perhaps also tell you that in the case where this issue is occurring for me, the kendo widget is in a popup window.  I am using ASP.NET MVC, and that popup window is loaded by making an ajax call to an MVC action that returns a View (not a PartialView).  That View is then populated into a div in the original view by setting its html property via javascript:

function loadPopupWindow (url, window, width, height, title) {
     var windowElement = $('#' + window).data("tWindow");
     $(windowElement.element).find(".t-window-content").css("height", height).css("width", width);
  
    $('#' + window + " .t-content").empty();
    $.ajax({
        url: url,
        success: function (data) {
            $('#' + window + " .t-content").html(data);
        },
        cache: false
    });
    windowElement.center().open();
}
0
Daniel
Telerik team
answered on 10 Jul 2013, 08:04 AM
Hello,

I posted my reply in the support ticket. In order to avoid duplication, lets continue the communication either in the forum or in the support thread.

Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Upload
Asked by
Shawn Taylor
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Shawn Taylor
Top achievements
Rank 1
Share this question
or