Error when downloading a file

  1. #1

    Error when downloading a file

    On the following example, we have a "Download File" button, that attempts do download a file from the server. As any server-side operation, an exception may occur and we have to handle it properly.

    On the following example, on ExampleController at line 9 the exception message is returned to the client.
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <script type="text/javascript">
            var DownloadFile = function () {
                Ext.net.DirectMethod.request({
                    url: Ext.net.ResourceMgr.resolveUrl("~/Example/DownloadFile"),
                    isUpload: true,
                    cleanRequest: true,
                    failure: function (response) {
                        Ext.Msg.alert("Ext.NET", response);
                    }
                });
            }
        </script>
    </head>
    <body>
        <ext:ResourceManager ScriptMode="Release" runat="server" />
        <ext:Button Text="Download File" runat="server">
            <Listeners>
                <Click Handler="DownloadFile();" />
            </Listeners>
        </ext:Button>
    </body>
    </html>
    namespace SandBox.Controllers
    {
        public class ExampleController : System.Web.Mvc.Controller
        {
            public ActionResult Index() => View();
    
            public ActionResult DownloadFile() => new AjaxResult
            {
                ErrorMessage = "Error From Server!"
            };
        }
    }
    It works as expected on Chrome
    Click image for larger version. 

Name:	up001.png 
Views:	55 
Size:	18.6 KB 
ID:	24735

    On FireFox
    Click image for larger version. 

Name:	up002.png 
Views:	51 
Size:	8.9 KB 
ID:	24736

    and on Edge
    Click image for larger version. 

Name:	up003.png 
Views:	43 
Size:	6.4 KB 
ID:	24737

    But on IE, the response is not as expected.
    Click image for larger version. 

Name:	up004.png 
Views:	55 
Size:	13.7 KB 
ID:	24738

    Any ideas to overcome the issue presented above.

    Thanks in advance.

    Note: the issue is also present on version 3.x.
  2. #2
    Any update?
  3. #3
    Any update?
  4. #4
    Hello Raphael! Sorry for the late response but I'm missing where are you pulling AjaxResult from. And for one, Google didn't help me finding to which namespace it belongs...
    Fabrício Murta
    Developer & Support Expert
  5. #5
    Ext.Net.MVC.AjaxResult
  6. #6
    Hello Raphael! Strange, how are you using it? Did you redefine it somewhere else?

    This class is not part of Ext.NET since 4.0.0-beta, according to issue #1259.

    Probably the problem with your implementation lies in being using it from a leftover DLL or something like it.
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. Replies: 2
    Last Post: Aug 30, 2013, 1:48 AM
  2. Downloading file after File Upload
    By karan in forum 2.x Help
    Replies: 0
    Last Post: Jul 29, 2013, 3:11 AM
  3. Replies: 2
    Last Post: Oct 20, 2012, 4:00 PM
  4. [CLOSED] BADRESPONSE downloading a file
    By vadym.f in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Feb 24, 2012, 4:12 PM
  5. downloading PDF file
    By unaltro2 in forum 1.x Help
    Replies: 0
    Last Post: Mar 10, 2011, 5:37 PM

Posting Permissions