Question

Maybe the title is not the best to describe the error. I'll try to describe what is happening.

First my scenario: I'm using "SAP Crystal Reports para Visual Studio 2010". This is part of code:

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Save(FacturaHeaderModel model, FormCollection formCollection)
{
...
var reporte = model.Movimiento.DescripLarga.ToLowerInvariant().Contains("compra")
                              ? System.Web.HttpContext.Current.Request.PhysicalApplicationPath + @"rpt\fact_compra.rpt"
                              : System.Web.HttpContext.Current.Request.PhysicalApplicationPath + @"rpt\fact_venta.rpt";
var rptH = new ReportClass { FileName = reporte };
rptH.Load();
rptH.RecordSelectionFormula = "{CtaCteCliente.CtaCteClienteId}=" + facturaId;              
var cnn = new ReportHelper(); //internal function to connect to the database all the sub reports in the report to show
cnn.Connect(rptH);
try
 {
  var stream = rptH.ExportToStream(ExportFormatType.PortableDocFormat);
  return File(stream, "application/pdf");
 }
 catch
 {
  return "Error";
 }
}

For some reason is not working and not showing any results. In other parts of the system are used called to reports with similar code and everything works normally.

What I can add here other information to properly diagnose the problem.

Edit: 02/09/2013

This is part of my view:

@using (Html.BeginForm("Guardar", "Facturas", FormMethod.Post))
{
<fieldset>
    <div class="editor-label" style="font-size:16px;">
        @Html.LabelFor(m => m.Movimiento.DescripLarga)
        <div class="editor-field">
            @Html.TextBoxFor(m => m.Movimiento.DescripLarga, new { @readonly = "readonly", style = "font-weight: bold;font-size:16px;" })
        </div>
    </div>
....
<input type="submit" name="Guardar" id="guardar" title="Guardar" value="Guardar" />
......
}

This is part of request and response:

 Encabezados de respuesta
 Cache-Control  private
 Connection Close
 Content-Length 42138
 Content-Type   application/pdf
 Date   Mon, 02 Sep 2013 21:30:53 GMT
 Server ASP.NET Development Server/10.0.0.0
 X-AspNet-Version   4.0.30319
 X-AspNetMvc-Version    3.0

 Encabezados de solicitud
 Accept */*
 Accept-Encoding    gzip, deflate
 Accept-Language    es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3
 Content-Length 340
 Content-Type   application/x-www-form-urlencoded; charset=UTF-8
 Host   xxxxx
 Referer    http://xxxxx/Facturas/Compras
 User-Agent Mozilla/5.0 (Windows NT 6.1; rv:23.0) Gecko/20100101 Firefox/23.0
 X-Requested-With   XMLHttpRequest

I'm imagining that the error actually is going through the kind of response that the client is waiting on the server you are sending. But should solve it?

Was it helpful?

Solution

After try the correct header for the form is:

@using (Html.BeginForm("Guardar", "Facturas", FormMethod.Post, new { enctype = "multipart/form-data" }))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top