Search code examples
iisasp.net-mvc-5listlabel

List&Label Webreporting: Export/Printing does not work on IIS Server


Hi and thank you in advance for any help,

I am trying to post a JSON-Object to an ASP.Net MVC-Server via JQuery/Ajax. The Controller method is supposed to take the JSON input and use it as a DataProvider for List&Label 22. The Report should then be generated and offered to the user as a PDF file for download. Since I want the structure of the JSON Object to be generic, I don't want to create a specific model in ASP.Net for this request, but rather pass over the JSON object as a string (I know that I might run into some size restrictions, but I will worry about that later :) ).

Here is my POST request:

<script>

function getReport() {
    //dummy data
    data = { JsonVariable1: 1, JsonVariable2: "JsonVariable2" };
    var dataSource = JSON.stringify(data);

    $.ajax({
        type: "POST",
        dataType: "text",
        url: "@Url.Action("/JsonTest")",
        data: "aDataSource=" + dataSource,
        async: false,
        success: function (result) {
            alert('Success!');
        }
    });
}

And this is the Controller method:

[HttpPost]
public ActionResult JsonTest(string aDataSource) {

    combit.ListLabel22.ListLabel vLL = new combit.ListLabel22.ListLabel();
    JsonDataProvider vJsonProvider = new JsonDataProvider(aDataSource);

    vLL.FileRepository = GetCurrentRepository();
    vLL.AutoProjectFile = mReportRepositoryId;
    vLL.DataSource = vJsonProvider;
    vLL.ExportOptions.Add(LlExportOption.ExportTarget, "PDF");
    vLL.Print();    //This causes problem on published server

    return Json("Success");
}

Locally, i.e. in my Visual Studio (2015) dev environment this works fine. However, when I publish the code to my IIS-Server, the POST-request doesn't terminate. I have found this line

vLL.Print();

to be the problem. If I comment out this line, the request terminates as expected. This line generates the report and exports it to a PDF which will in turn be offered to the user as a download.
I'm using IIS 8.5 and .NET-Framework 4.5 on a Machine running Windows Server 2012 R2. A Printer Driver is installed and the regular List&Label funcationality is working (e.g. starting the web designer, previewing reports via HTML, etc).

Does anyone have any idea what I am missing here? I am not a web developer, and I may also have forgotten to adjust some configurations on my IIS Server.

Thanks!


Solution

  • Just calling the Printmethod is not enough as you need to tell List & Label where to generate the report. I'd rather use the Export method (as it wires up a number of convenient things like muting the file dialogs) in this way:

    string reportResult = "Report." + Guid.NewGuid() + ".pdf";
    string outputFile =  Server.MapPath("~/exports/") + reportResult;
    ExportConfiguration exportConfiguration = new ExportConfiguration(LlExportTarget.Pdf, outputFile, mReportRepositoryId);
    vLL.Export(exportConfiguration);
    

    You should then find your PDF in the "exports" path of your web application on the server. To troubleshoot issues like this you can use the provided debugging tool Debwin4. It shows you all calls to the API and hints on missing options or input.