如何解决无效的 URI:无法确定 URI 的格式
我正在开发一个应用程序,该应用程序通过图像获取名称等信息,然后打印卡片。我正在使用 RDLC 报告的图像路径。
这里我设置的是上传图片到 Files 文件夹后的路径:
protected void UploadFile(object sender,EventArgs e)
{
string folderPath = Server.MapPath("~/Files/");
//Check whether Directory (Folder) exists.
if (!Directory.Exists(folderPath))
{
//If Directory (Folder) does not exists Create it.
Directory.CreateDirectory(folderPath);
}
//Save the File to the Directory (Folder).
FileUpload1.SaveAs(folderPath + Path.GetFileName(FileUpload1.FileName));
//Display the Picture in Image control.
_imageUrl = Image1.ImageUrl = "~/Files/" + Path.GetFileName(FileUpload1.FileName);
}
点击按钮
protected void txtPrint_Click(object sender,EventArgs e)
{
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.Visible = true;
ReportViewer1.LocalReport.ReportPath = this.Context.Server.MapPath(@"~/Cards/Greetings.rdlc");
ReportViewer1.LocalReport.EnableExternalImages = true;
List<ReportParameter> param = new List<ReportParameter>();
if (!string.IsNullOrEmpty(txtName.Text))
param.Add(new ReportParameter("Name",txtName.Text));
else
param.Add(new ReportParameter("Name"," "));
param.Add(new ReportParameter("Gender",ddlGender.SelectedValue));
param.Add(new ReportParameter("Designation",""));
if (!string.IsNullOrEmpty(Image1.ImageUrl)) {
// this line is causing the issue
param.Add(new ReportParameter("pImageUrl",new Uri(Image1.ImageUrl).AbsoluteUri));
}
ReportViewer1.LocalReport.SetParameters(param);
... rest of the code
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。