Nov 03, 2010, 10:17 PM
[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:
Regards,
Tadeusz
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 6:00 AM.
Reason: [CLOSED]