[CLOSED] [1.0] MVC and Exception reporting during file upload in IE not working

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] [1.0] MVC and Exception reporting during file upload in IE not working

    Hi,

    It's been a long time I took updates and after I recently did so, my MVC error reporting framework stopped working under IE (it was all working well before). I can replicate the problem with your MVC sample application (I took it from http://extnet-mvc.googlecode.com/svn/trunk) with the changes below. The code is very simple just to illustrate the problem. After the changes follow these steps:

    1. Login to the application and go to http://localhost:YOUR_PORT_HERE/Home/Form
    2. select a file for upload
    3. click submit
    4. under FireFox (I use 3.6.12) an error will be displayed which is the correct behavior
    5. under IE (I use 8) the alert box saying 'success' will be displayed, which is wrong.

    The code changes:

    Add this class:
    [AttributeUsage( AttributeTargets.Method | AttributeTargets.Class, Inherited = true, AllowMultiple = true )]
        public class ExceptionFilterAttribute : FilterAttribute, IExceptionFilter
        {
            public void OnException( ExceptionContext filterContext )
            {
                if ( filterContext.ExceptionHandled )
                {
                    return;
                }
                filterContext.ExceptionHandled = true;
                filterContext.HttpContext.Response.StatusCode = 500;
                filterContext.HttpContext.Response.TrySkipIisCustomErrors = true;
                filterContext.Result = new AjaxResult
                {
                    ErrorMessage = "Error",
                    IsUpload = true
                };
            }
        }
    Change the HomeController.SaveForm method to this:


    [ExceptionFilter]
            public AjaxFormResult SaveForm(string txtName, string txtEmail, string txtComments)
            {
                throw new ApplicationException();
            }
    Change Form.aspx file to this:

    %@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    
        <script type="text/javascript">        
            var failureHandler = function(form, action) {            
                Ext.MessageBox.show({
                    title: 'Failure',
                    msg: action.result.errorMessage,
                    buttons: Ext.MessageBox.OK,
                    icon: Ext.MessageBox.ERROR
                });
            };
    
            var success = function(form, action) {
                alert('success');
            };
        </script>
    
    </head>
    
    <body>
        <ext:ResourceManager runat="server" ScriptMode="Debug" />
        
        <ext:FormPanel 
            ID="FormPanel1" 
            runat="server" 
            Url="~/Home/SaveForm/"
            Border="false" 
            FileUpload="true"
            BodyStyle="padding:5px 5px 0px;" 
            Layout="form"       
            LabelAlign="Top">
            <Items>
                <ext:Panel runat="server" Border="false" Height="100">
                    <Items>
                       <ext:FileUploadField runat="server" ButtonText="..."/>                    
                    </Items>
                </ext:Panel>                   
            </Items>
            <Buttons>
                <ext:Button runat="server" Text="Send">
                    <Listeners>
                        <Click Handler="#{FormPanel1}.getForm().submit({ waitMsg : 'Sending...', success : success, failure: failureHandler });" />
                    </Listeners>
                </ext:Button>
            </Buttons>
        </ext:FormPanel>
    </body>
    </html>
    I used Ext.NET compiled freshly from SVN. Is this a bug or the whole process needs some different handling?

    Regards,
    Tadeusz
    Last edited by Daniil; Nov 08, 2010 at 7:00 AM. Reason: [CLOSED]
  2. #2
    Hi,

    Unfortunately, I cannot reproduce it. I see error message under IE8.
    Do you use MVC2?
    Can you create test project, zip it (with assemblies) and send me (vladimir@object.net)?
    Vladimir Shcheglov
    Sr. Developer
  3. #3
    Hi,

    In my original project we use MVC1, but in the project I replicated, MVC2 got referenced.

    I have sent you the complete project by email.

    Tadeusz
  4. #4
    Hi,

    Unfortunately, your test project still shows error message under IE8.
    What OS do you use? I tested under Vista.

    Can you set breakpoint ('debugger';) in the success handler (please ensure that debug is enabled in IE8)? Under VS you can go through Call stack to understand why success handler is called

    Is the the issue reproducible with IsUpload mode only?
    Vladimir Shcheglov
    Sr. Developer
  5. #5
    Hi,
    I use Windows 7 x64. I know the other developer has replicated this on his machine too, but I don't know which system he is using.

    Yes, the issues can be reproduced only with IsUpload.

    I went up the stack trace to the Ext.form.Action.Submit.success method. I indicated below which line is called. result is true. response is:
    {argument: undefined, responseText: "", responseXML: null}

        success : function(response){
            var result = this.processResponse(response);
            if(result === true || result.success){
    // THIS LINE IS CALLED:
                this.form.afterAction(this, true);
                return;
            }
            if(result.errors){
                this.form.markInvalid(result.errors);
            }
            this.failureType = Ext.form.Action.SERVER_INVALID;
            this.form.afterAction(this, false);
        },
    I went up the stack even more to the cb() function in Ext.data.Connection.doFormUpload and this line:

    doc = frame.contentWindow.document || frame.contentDocument || WINDOW.frames[id].document;
    throws an exception "description = "'$lineinfo' is undefined".

    When I enter any of the above (e.g. frame.contentWindow.document) into the watch window, I get "Access is denied" or "Permission denied".

    As the exception is thrown and caught shortly after, runCallback(o.success, o.scope, [r, o]); method is executed with r set to default values. Then when Ext.Action.processResponse examines it, it returns true because this condition evaluates to true:

    if(!response.responseText && !response.responseXML)
    Let me know if you need any more information.

    Tadeusz
  6. #6
    Hi,

    I guess that it is IE8 bug under Windows 7 because doFormUpload is not changed in 3.x version. If we cannot get iframe response then we cannot handle the failure case.

    Google shows that the problem occurs in another toolkits also under Windows7 x64
    Can you you check Windows Update service and apply all available updates for IE8?

    Another option I can suggest to try: override doFormUpload method and replace the following line in that method
    Ext.EventManager.on(frame, LOAD, cb, this);
    by
    Ext.EventManager.on(frame, LOAD, function(){ cb.defer(100, this);}, this);
    Vladimir Shcheglov
    Sr. Developer
  7. #7
    Hi,

    I found one changes in doFormUpload
    3.1.1 code
    Ext.fly(frame).set({
                    id: id,
                    name: id,
                    cls: 'x-hidden'
                });
    
                doc.body.appendChild(frame);
    
                //Reset the Frame to neutral domain
                Ext.fly(frame).set({
                   src : Ext.SSL_SECURE_URL
                });
    3.3.0 code
    Ext.fly(frame).set({
                    id: id,
                    name: id,
                    cls: 'x-hidden',
                    src: Ext.SSL_SECURE_URL //this line was added
                }); 
    
                doc.body.appendChild(frame);
                // block was removed
    Vladimir Shcheglov
    Sr. Developer
  8. #8
    Hi,

    Adding cb.defer didn't help and neither did the Ext.SSL_SECURE_URL, but when I removed setting HTTP status to 500 in the exception filter, then it works. I don't yet what other implications it will have, but I will test it.

    Regards,
    Tadeusz
  9. #9
    Unfortunately, when status is set to 200, the regular Ajax responses are treated as successful ones. That because Ext.lib.Ajax.handleTransactionResponse checks out the status code to determine the success or failure. Seems like an impossible thing to solve.
  10. #10
    Hi,

    I have ugly workaround: to make second request in the success handler to check previous upload status but this workaround requires to save status somewhere (for example, TempData) (also two requests is bad practice also)
    Vladimir Shcheglov
    Sr. Developer
Page 1 of 2 12 LastLast

Similar Threads

  1. [CLOSED] multiple file upload and file size at client side
    By mirwais in forum 1.x Premium Help
    Replies: 24
    Last Post: Dec 15, 2014, 6:44 AM
  2. [CLOSED] File upload control not working in IE8
    By majestic in forum 1.x Premium Help
    Replies: 12
    Last Post: Dec 15, 2011, 5:02 PM
  3. Replies: 1
    Last Post: Jun 23, 2011, 10:37 AM
  4. [CLOSED] file upload - file name is empty
    By stoque in forum 1.x Premium Help
    Replies: 2
    Last Post: May 11, 2011, 9:06 PM
  5. [CLOSED] Help with file upload
    By smart+ in forum 1.x Premium Help
    Replies: 5
    Last Post: Sep 09, 2010, 9:02 PM

Posting Permissions