Sep 01, 2016, 12:27 PM
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.
On FireFox
and on Edge
But on IE, the response is not as expected.
Any ideas to overcome the issue presented above.
Thanks in advance.
Note: the issue is also present on version 3.x.
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 ChromeOn FireFox
and on Edge
But on IE, the response is not as expected.
Any ideas to overcome the issue presented above.
Thanks in advance.
Note: the issue is also present on version 3.x.