无法在aspx页面中加载图像 [英] Not loading images in an aspx page

查看:90
本文介绍了无法在aspx页面中加载图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在asp.net应用程序.我有一个名为First.UI的网站,我使用使用文件系统发布"选项发布了该网站.
使用IIS7,我创建了一个名为FirstWebSite的应用程序,并将其映射到"Default AppPool".
我可以在FirstWebsite中看到Images文件夹.
问题是,每当我浏览任何页面时,它都不会显示图像.
当我看到路径时,它显示为"localhost/images/imagename.jpg",我认为该路径不正确.因此,它不会加载图像.
加载图像的实际路径是"localhost/FirstWebsite/images/imagename.jpg",我不明白为什么它不采用此路径.

请让我知道这里的错误是什么. CSS也发生同样的事情.

在此先感谢

问候
Dayakar D.N

Hi,

I am working asp.net application. I have one web site called First.UI and I published this using Publish with Filesystem option.
Using IIS7, I created application say FirstWebSite and I mapped this to "Default AppPool".
I am able to see Images folder inside the FirstWebsite.
The issue is that whenever I am browsing any page, it is not showing the images.
When I see the path it is showing like "localhost/images/imagename.jpg" I think this path is incorrect. Hence it is not loading the image.
The actual path to load the image is "localhost/FirstWebsite/images/imagename.jpg" and I don''t why it is not taking this path.

Kindly let me know what is the mistake here. The same thing happening for css also.

Thanks in Advance

Regards
Dayakar D.N

推荐答案

使用类似
的图像路径
''images/imagename.jpg''或
''../images/imagename.jpg''或
''〜/images/imagename.jpg''

在您的图片标签中.肯定有一种方法对您有帮助.
Use image path like

''images/imagename.jpg'' or
''../images/imagename.jpg'' or
''~/images/imagename.jpg''

in your image tag. Surely one method will help you.


听起来像是相对路径问题.有时,在部署之后,无法正确形成被引用为图像,样式表等来源的路径.这会导致在所引用的位置找不到文件,因为未下载图像或未应用样式表.
您需要确保路径正确,以便找到并使用该文件.

我建议您使用此技巧并在设置文件源之前正确解析路径:
Sounds like it is relative path issue. At times, after deployment the path referenced as a source for images, stylesheets, etc is not correctly formed. This leads to no file found at the location referred because of which images don''t download or style-sheets does not get applied.
You would need to make sure that the path is correct such that file is found and used.

I would suggest you to use this Tip and resolve the path correctly before setting the source of the file: Resolving Paths in a Multi-Folder WebSite[^]


这篇关于无法在aspx页面中加载图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆