【发布时间】:2011-11-01 11:07:26
【问题描述】:
我正在尝试调用多个 SQL Reporting Services 报告,取回 .pdf,然后将它们附加在一起。我在附加 .pdf 文件时没有问题,但在第二份报告中出现错误。下面是一些示例代码:
Dim httpReq As System.Net.HttpWebRequest = DirectCast(System.Net.WebRequest.Create(strLink), System.Net.HttpWebRequest)
Dim creds As New System.Net.NetworkCredential
creds.Domain = "MyDomain"
creds.UserName = "UserName"
creds.Password = "Password"
httpReq.Credentials = creds
Dim httpResp As System.Net.HttpWebResponse = DirectCast(httpReq.GetResponse(), System.Net.HttpWebResponse)
httpResp.Close()
httpReq = Nothing
httpResp = Nothing
Dim SecondHttpReq As System.Net.HttpWebRequest = DirectCast(System.Net.WebRequest.Create(strSecondLink), System.Net.HttpWebRequest)
SecondHttpReq.Credentials = creds
Dim SecondHttpResp As System.Net.HttpWebResponse = DirectCast(SecondHttpReq.GetResponse(), System.Net.HttpWebResponse)
当我尝试创建第二个 HttpResponse 时,我收到 401 Unauthorized 错误。当我检查 SecondHttpReq 对象出错时,我发现 Credentials 属性已被设置回 Nothing。我试过使用 CookieContainer 无济于事。我真的不想写一个父/子报告来把这些放在一起,所以我想听听其他选择。提前致谢。
【问题讨论】: