Welcome Guest Search | Active Topics | Sign In | Register

AJAXUploader error in FireFox Options
OneMHz
Posted: Thursday, February 28, 2008 5:48:56 AM
Rank: Newbie
Groups: Member

Joined: 9/13/2007
Posts: 4
I'm having an issue with the uploader control in FireFox. It only occurs on the production server, not my development environment (localhost). The error from the Error Console is

Error: [Exception... "'Permission denied to get property XMLDocument.documentElement' when calling method: [nsIOnReadyStateChangeHandler::handleEvent]" nsresult: "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)" location: "<unknown>" data: no]

The only differences between the two environments is that one is localhost and one is not and that the production environment has debugging="false" in the web.config.

What is causing this?
eo_support
Posted: Thursday, February 28, 2008 6:12:14 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

That is a cross domain JavaScript permission issue. Usually if you host your main website in one domain name and then have a page in an iframe from another domain, you would run into such problem. Cross domain JavaScript is always disallowed for security reasons, so the only solution is to change the website design to avoid such scenarios.

If that's not your case, please post the Url of your page and we will take a look to see what we can find.

Thanks
OneMHz
Posted: Thursday, February 28, 2008 6:46:51 AM
Rank: Newbie
Groups: Member

Joined: 9/13/2007
Posts: 4
I know of the cross domain scripting issue. I actually just changed it to avoid this problem. I did have the uploader form in an iFrame, but I changed it so that the user is directed to a standalone page that is just the uploader form, and when they're done with the upload, they're directed back to the main application. Unfortunately, the site has some sensitive information, so it wouldn't be possible for you to access it. But I could post some code. My Page_Load just does some security checks and sets up some URLs. The FileUploaded handler logs that a file was uploaded, then copies it to a directory based on the user who uploaded the file. That's the entirety of the application for doing the uploading. It is an unfortunate requirement, but this must be separate from the main application because file uploads have to go to another server, without touching the application server (PITA).

Code: HTML/ASPX
<%@ Page Language="C#" MasterPageFile="~/Default.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="FileUpload._Default" %>
<%@ Register Assembly="EO.Web" Namespace="EO.Web" TagPrefix="eo" %>

<asp:Content ID="defaultContent" ContentPlaceHolderID="cpCatalogContent" Runat="Server">
<script type="text/javascript">

var lastFileName = "";
var uploadComplete = false;

function CustomProgressHandler(uploader, total, received)
{
    var minutesRemaining = new Number(uploader.getEstimiatedSecondsRemaining() / 60);
    var secondsRemaining = uploader.getEstimiatedSecondsRemaining() % 60;
    
    var kUploaded = new Number(uploader.getTransferredBytes() / 1024);
    var kTotal = new Number(uploader.getTotalBytes() / 1024);
    var kSpeed = new Number(uploader.getSpeed() / 1024);
    
    var progressText = document.getElementById("<%=lblProgressText.ClientID %>");
    progressText.innerHTML = "Uploaded " + kUploaded.toFixed(2) + "k of " + kTotal.toFixed(2) + "k (" + kSpeed.toFixed(2) + "k/s). Estimated " + minutesRemaining.toFixed(0) + ":" + padSeconds(secondsRemaining) + " until complete.";
}

function padSeconds(original)
{
    original = original + "";
    if(original.length == 1)
    {
        return "0" + original;
    }
    
    return original;
}

function UploadingComplete()
{
    $get("<%= btnFinished.ClientID %>").click();
}

</script>
<asp:Panel ID="pnlBody" runat="server" CssClass="body">
    <asp:Panel ID="pnlUploader" runat="server">
        <asp:Label ID="lblHeading" runat="server">Please select the file you want and click upload.  Do not navigate away from this page while uploading.  When upload is complete, you will be directed back to the file list automatically.  Navigating away from this page or closing your browser will cancel the upload. Maximum upload duration is 15 hours.</asp:Label><br /><br />
        <asp:HyperLink ID="hypReturn" runat="server">Return to File List</asp:HyperLink><br />
        <eo:AJAXUploader ID="auFileUploader" runat="server" Width="400px" AutoPostBack="true" OnFileUploaded="auFileUploader_FileUploaded" ClientSideOnProgress="CustomProgressHandler">
            <LayoutTemplate>
                <table style="width:400px; margin:0px; padding: 2px;">
                    <tr>
                        <td colspan="2"><asp:PlaceHolder ID="InputPlaceHolder" runat="server">Input Place Holder</asp:PlaceHolder></td>
                    </tr>
                    <tr>
                        <td><eo:ProgressBar ID="ProgressBar" runat="server" ControlSkinID="none" Height="16px" Width="175px" BorderColor="336699" BorderStyle="solid" BorderWidth="1px" IndicatorColor="151, 198, 232" ShowPercentage="true"></eo:ProgressBar></td>
                        <td style="text-align: right; padding-right: 3px;">
                            <asp:Button ID="UploadButton" runat="server" Text="Upload" Width="82px" /><br />
                            <asp:Button ID="CancelButton" runat="server" Text="Cancel" Width="82px" />
                        </td>
                    </tr>
                </table>
            </LayoutTemplate>
        </eo:AJAXUploader>
        <div><asp:Label ID="lblProgressText" runat="server"></asp:Label></div>
    </asp:Panel>
    <asp:Panel ID="pnlError" runat="server" Visible="false" CssClass="errorPanel">
        <asp:Label ID="lblError" runat="server" CssClass="errorText"></asp:Label>
    </asp:Panel>
</asp:Panel>
<asp:HiddenField ID="hdnReferrer" runat="server" />
<asp:HiddenField ID="hdnFileName" runat="server" />
<asp:HiddenField ID="hdnFileSize" runat="server" />
<asp:Button ID="btnFinished" runat="server" CssClass="hidden" />
<iframe class="hidden" style="width: 0px; height: 0px; margin: 0px; padding: 0px;" src="http://localhost/Portal/System/SessionKeepAlive.aspx"></iframe>
</asp:Content>
eo_support
Posted: Thursday, February 28, 2008 8:36:12 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

I do not see anything particular strange in your code, except for the keepAlive iframe, which should not cause any problem but you may want to try commenting it out to see what happens.

A few other things that you want to try are:

1. Do not use server side Response.Redirect. Try use a meta refresh in your header, or render some JavaScript code to the client and then do a client side redirect;
2. I am not sure how UploadingComplete is called. You may want to delay calling it. For example, instead of calling it directly, try call it by window.setTimeout("UploadingComplete()", 10);
3. Replace $get("<%= btnFinished.ClientID %>").click() with a direct __doPostBack call;

The bottom line is this definitely has to do with the cross domain situation. While the page is a standalone page, the way that it is entered and departed might be causing the issue. So I would focus on that.

Thanks
OneMHz
Posted: Thursday, February 28, 2008 9:01:38 AM
Rank: Newbie
Groups: Member

Joined: 9/13/2007
Posts: 4
I think I've found the issue. It was something I had already changed, but for some reason (caching maybe) the behavior didn't change when I was testing. I'd been setting the document.domain to the parent on both the main app and the uploader form pages when it was in an iframe in the main app, so that the javascript could work (at least in IE...). When I was writing my previous reply, I thought of that, but I'd already taken it out and it was still broken. I just tried again and now it's working!

In other words, you were right about the cross domain issue, but my browser was pouting.

Thanks for your fast responses. You guys have some of the best dev support around!
eo_support
Posted: Thursday, February 28, 2008 9:17:50 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Cool. Glad you found it!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.