Search code examples
c#model-view-controllerreporting-serviceshttp-postwebclient

C# MVC Download SSRS Report as PDF File passing Parameter data as Post Request


I've set up a short test for creating a SSRS report and Downloading it as PDF via an MVC Website.

private static string _report = @"http://myServer/ReportServer?/Test&s:Command=Render&rs:Format=pdf&Param1={0}&Param2={1}";

public FileResult DownloadReport() {
    using (var client = new WebClient()) {
        client.Credentials = CredentialCache.DefaultCredentials;
        var data = client.DownloadData(String.Format(_report, "MyParam1Value", "MyParam2Value");
        return File(data, "application/pdf", "YourReport.pdf");
    }
}

This is working fine so far.

But for the Report im planning to do i will have a lot of Parameters with large data. So im worried that im reaching the maximum lenght of the URL. Is there a way to pass the Parameter data as POST request, so that its not in the URL?

Thank you all


Solution

  • I have found a Solution, or workaround.. :-)

    I will store all the data in a Db an just pass the id of the created record to the report.

    It was for my usecase not neccessary to store the data in a Db, but its also not a problem.

    If someone still would know how to pass the parameters via Post Request, then feel free to answer. Maybe someone else needs it.

    Thank you all