所以我已经关注了这个网站(Exporting SSRS Report to PDF in MVC Action)和其他各种代码,但似乎没有任何效果。我希望在mvc的网页上有一个链接,它将以PDF格式下载报告。网址我浏览的网址很好但是我一直收到这个错误:"远程服务器返回错误:(401)未经授权。"在mvc。这是我目前的代码:
public ActionResult Download()
{
var url = "http://xxxx/ReportServer/Pages/ReportViewer.aspx?%2fxxx+xxx%2fxxx+Report&rs:Command=Render&CellNumber=";
NetworkCredential nwc = new NetworkCredential("xxx", "xxx", "xxx");
WebClient client = new WebClient();
client.Credentials = nwc;
client.UseDefaultCredentials = false;
string reportURL = String.Format("{0}{1}{2}", url, Cellphone, "&rs:Format=PDF");
return File(client.DownloadData(reportURL), "application/pdf");
}
当我删除它授权的"&rs:Format=PDF"
部分时,然后该应用程序失败。
请帮助。