gpt4 book ai didi

带有外部图像的 ASP.NET rdlc 不以 PDF 显示图像

转载 作者:行者123 更新时间:2023-12-04 09:34:01 24 4
gpt4 key购买 nike

我正在使用 ASP.NET 附带的 Microsoft ReportViewer,并且有一个报告参数应该在我的报告中设置图像的值(路径)。我现在将路径作为完整的 URL 提供,从 http://开始,但也尝试将其作为应用程序相对路径、站点根路径等,并且由于某种原因,当图像始终显示为红色 X 时它导出为 PDF。我只是在代码中创建一个控件实例,设置属性并直接导出到响应流,以便它执行下载。

我只是不确定图像没有显示是什么问题,所以如果有人有任何想法,请告诉我。

更新 1

我已经确定如果图像在我的公共(public) Web 服务器上,我可以使用 URL 嵌入图像,但是当我在 localhost 中运行时,图像不会嵌入。我已经为 localhost 确认,如果我将相同的 URL 粘贴到浏览器中,图像将正常打开。据我所知,我没有代理。所以我可以解决我的问题,但我仍然不明白 localhost 的问题是什么。

更新 2

忘了提一下,当从浏览器打开图像的 URL 时,它可以正常工作。

最佳答案

我解决了这个问题:

//For local relative paths
string imgUrl = new Uri(HttpContext.Current.Server.MapPath("~/images/mylocalimage.jpg")).AbsoluteUri;

// OR

// For complete URLs
{
ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; // This allows reportViewer to download image from url
string imgUrl = /* Your image URL ("http://") */;
}
//Then pass imgUrl parameter as external source of your image.

关于带有外部图像的 ASP.NET rdlc 不以 PDF 显示图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1268820/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com