简体   繁体   English

从asp.net中的xml文件加载时图像不显示

[英]Image not displaying when loaded from xml file in asp.net

I have a folder on the desktop with images. 我在桌面上有一个包含图像的文件夹。 i have their paths in an xml file. 我在xml文件中有它们的路径。 when i try to use the image path the image does not appear. 当我尝试使用图像路径时,图像不会出现。 But when i have the image folder within my solution then its working fine. 但是当我在解决方案中包含图像文件夹时,它的工作正常。 Below is my xml file. 下面是我的xml文件。

   <?xml version="1.0" encoding="utf-8" ?>
  <ImagesXml>
  <Ad>
<ImageUrl>~/Images/bravo_bronze.jpg</ImageUrl>
<AlternateText>Img1</AlternateText>
<ImageUrl1>~/Images/bravo_star.jpg</ImageUrl1>
<ImageUrl2>C:\Users\273714\Desktop\Certificate_images\bravo_bronze - Copy</ImageUrl2>
<ImageUrl3>C:\Users\273714\Desktop\Certificate_images\bravo_star-Copy</ImageUrl3>
<ImageUrl4>~/Images/bravo_bronze - Copy (2).jpg</ImageUrl4>

  </Ad>
 </ImagesXml>

I need to use the image path here 我需要在这里使用图像路径

   protected void Page_Load(object sender, EventArgs e)
       {
          XmlDocument xmldoc = new XmlDocument();
        string file = HttpContext.Current.Server.MapPath("XMLFile1.xml");
        xmldoc.Load(file);
        Image2.ImageUrl = xmldoc.SelectSingleNode("ImagesXml/Ad/ImageUrl2").InnerText;
        Image1.ImageUrl = xmldoc.SelectSingleNode("ImagesXml/Ad/ImageUrl3").InnerText;
     }

In the aspx file i hv the image tags. 在aspx文件中,我hv图像标签。 Any suggestions will be helpful 任何建议都会有帮助

It looks like you are trying to serve the images from a webpage. 您似乎正在尝试从网页中投放图像。 They need to be hosted on the web server. 它们需要托管在Web服务器上。 The local files paths will not work 本地文件路径不起作用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM