尝试通过 WebRequest 对象执行 SSRS 报告。获取响应的调用给出了“500 Internal Server Error”,没有更多信息(我检查参数值等在浏览器中是否有效)
我调试抓取网址,并将其粘贴到浏览器中,它成功运行。
http://devBI/ReportServer?%2fSSRS+Project%2fValuationReport&rs:Command=Render&rs:Format=EXCEL&ReportDate=23/06/2013&ClientCode=QWECT&IsEOM=0
有问题的代码是:
WebRequest Request = HttpWebRequest.Create(reportUrl);
Request.Credentials = CredentialCache.DefaultCredentials;
log.Debug("Credentials for request: " + Request.Credentials.ToString());
if (config.UseInfiniteTimeout)
{
Request.Timeout = System.Threading.Timeout.Infinite;
}
else
{
Request.Timeout = config.TimeoutSeconds * 1000;
}
Request.Method = "GET";
try
{
HttpWebResponse Response = (HttpWebResponse)Request.GetResponse();
using (Stream ResponseStream = Response.GetResponseStream())
{
string responseString;
StreamHelper.CopyStream(Response.GetResponseStream(), out responseString);
ResponseStream.Flush();
ResponseStream.Close();
log.Debug("Response string: " + responseString);
return responseString;
}
}
catch (Exception e)
{
log.Error("Error encountered during WebRequest/Response: " + e.ToString());
throw;
}