Error 500 when downloading an xlm via iframe;

Asked

Viewed 33 times

1

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 at least peculiar. The same is not able to export the file and the return is a 500 error;

Here is the iframe construction:

    _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 Formulaimport.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 does not generate me error log just gives me the image error below:

Erro mistico sem explicação.

My biggest problem is that I don’t understand what the hell is going on here... Should I have set the maximum header size? It’s some bullshit on Iss, but if it is, shouldn’t it give a specific IIS error instead of the 500? Any hint?

1 answer

-1

Browser other questions tagged

You are not signed in. Login or sign up in order to post.