Script5: Access is denied intermittent error on Kendo file upload

4 posts, 0 answers
  1. Shawn Taylor
    Shawn Taylor avatar
    5 posts
    Member since:
    Sep 2009

    Posted 03 Jul 2013 Link to this post

    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");
        }
    }
  2. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 05 Jul 2013 Link to this post

    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!
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Shawn Taylor
    Shawn Taylor avatar
    5 posts
    Member since:
    Sep 2009

    Posted 08 Jul 2013 Link to this post

    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();
    }
  5. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 10 Jul 2013 Link to this post

    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!
Back to Top
UI for ASP.NET MVC is VS 2017 Ready