【发布时间】:2011-04-18 06:40:15
【问题描述】:
我正在尝试使用 Azure Reporting Services 以编程方式呈现 PDF。我怀疑实际的 PDF 检索很好,但在请求报告(通过 URL)之前我找不到验证连接的方法。我在我的 Web 应用程序的服务层工作,我不能使用 Web 引用(可能不适用于 Azure),并且使用 ReportViewer 控件没有意义(因为它是一种服务层方法)。
我有所有要连接的详细信息,但我怀疑我需要一个 cookie 来进行身份验证,但我不确定如何手动创建它。有什么建议/解决方案吗?
到目前为止,这是我的代码:
string userName = BJConfigurationManager.GetSetting("ReportingServiceUsername");
string password = BJConfigurationManager.GetSetting("ReportingServicePassword");
NetworkCredential networkCredential = new NetworkCredential(userName, password);
Domain.Report report = GetReportById(id);
int timeout = 30; //seconds
string url = "https://bleh.ctp.reporting.database.windows.net/ReportServer/Pages/ReportViewer.aspx?...";
string destinationFileName = "@C:\\Temp.pdf";
// Create a web request to the URL
HttpWebRequest MyRequest = (HttpWebRequest)WebRequest.Create(url);
MyRequest.PreAuthenticate = true;
MyRequest.Credentials = networkCredential;
MyRequest.Timeout = timeout * 1000;
try
{
// Get the web response -- THE RESPONSE COMES BACK AS UNAUTHENTICATED...
HttpWebResponse MyResponse = (HttpWebResponse)MyRequest.GetResponse();
【问题讨论】:
标签: authentication reporting-services azure