Good afternoon, I have a WEB application with EXTJS with the option to export a report in XML format through a POST via ashx, currently one of the clients that has this application is reporting a problem in the least peculiar. The same is not able to export the file and the return is a 500 error;
Here is the iframe construct:
_exportarFormulario: function ()
{
var body = Ext.getBody();
if (!this.frameExportarHidden)
{
this.frameExportarHidden = body.createChild({
tag:'iframe'
,cls:'x-hidden'
,id:'iframeExportar'
,name:'iframeExportar'
});
}
if (!this.formExportarHidden)
{
this.formExportarHidden = body.createChild({
tag:'form'
,cls:'x-hidden'
,id:'formExportar'
,method: 'POST'
,action: "FormularioImportacao.ashx?sessionID=0E72435340AE43C48293922D17C2CB06&fnTarget=ExportarFormulario&formularioId=646"
,target:'iframeExportar'
});
}
this.formExportarHidden.dom.submit();
}
Inside the Form.Import.ashx I have the fear that will process the request.
public class FormularioImportacao : IHttpHandler
{
protected static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
String fnTarget = context.Request["fnTarget"];
//recupera a informação do método usando reflection
MethodInfo methodInfo = this.GetType().GetMethod(fnTarget, BindingFlags.NonPublic | BindingFlags.Instance);
try
{
methodInfo.Invoke(this, new object[] { context });
}
catch (Exception e)
{
string erro = e.Message;
if (e.InnerException != null)
erro = e.InnerException.Message;
context.Response.Write("{'success': false, 'mensagem': '" + erro.Replace("'", "\"") + "'}");
}
}
// E respectivamente, o metodo para exportar o formulário
private void ExportarFormulario(HttpContext context)
{
int formularioId = Convert.ToInt32(context.Request["formularioId"]);
Formulario formulario = new Formulario();
try
{
context.Response.Clear();
context.Response.ContentType = "text/xml";
context.Response.Charset = "iso-8859-1";
context.Response.ContentEncoding = Encoding.GetEncoding("iso-8859-1");
context.Response.AddHeader("Content-Disposition", "attachment; filename=\"FRM_" + formularioId.ToString() + ".xml\"");
context.Response.Write(formulario.ExportarFormulario(formularioId));
context.Response.Flush();
context.Response.Close();
}
catch (System.Exception e)
{
ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
log.Error(null, e);
}
}
The problem is that even with try / catch it does not generate error logging just gives me the error of the image below:
My biggest problem is that I do not understand what the hell is going on here ... Should I have set the maximum size in the header? is some crap in iss, but if so should not it give a specific IIS error instead of 500? Any tips?