简体   繁体   English

C# MVC 下载 SSRS 报告为 PDF 文件传递参数数据作为 Post 请求

[英]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.我设置了一个简短的测试来创建 SSRS 报告并通过 MVC 网站将其下载为 PDF。

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.所以我担心我会达到 URL 的最大长度。 Is there a way to pass the Parameter data as POST request, so that its not in the URL?有没有办法将参数数据作为 POST 请求传递,使其不在 URL 中?

Thank you all谢谢你们

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.我将所有数据存储在数据库中,只需将创建记录的 id 传递给报告。

It was for my usecase not neccessary to store the data in a Db, but its also not a problem.对于我的用例而言,不必将数据存储在 Db 中,但这也不是问题。

If someone still would know how to pass the parameters via Post Request, then feel free to answer.如果有人仍然知道如何通过 Post Request 传递参数,请随时回答。 Maybe someone else needs it.也许其他人需要它。

Thank you all谢谢你们

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM