简体   繁体   English

图片未显示在网页上

[英]Image is not displaying on web page

<asp:Image ID="Image11"  runat="server" Height="100px" Width="100px" />

VB.net code is here VB.net代码在这里

  logo_path = Server.MapPath(Request.ApplicationPath & "/" & "Logo" & "/" & img_name)

    da.Dispose()

    dr.Close()

    Image11.ImageUrl = logo_path

    Session("curr_page_path") = logo_path

During debugging time the logo_path that is global variable displays the full path of the image with image name but on web page there is no image... 在调试期间,作为全局变量的logo_path使用图像名称显示图像的完整路径,但在网页上没有图像...

Request.ApplicationPath will be something like C:\\Inetpub\\wwwroot . Request.ApplicationPath将类似于C:\\Inetpub\\wwwroot This is not what you want in the browser. 不是您在浏览器中想要的。 The browser needs a URL like http://www.example.com/Logo/image1.jpg . 浏览器需要类似http://www.example.com/Logo/image1.jpg的URL。 Or as the browser knows which web site it is on, just Logo/image1.jpg would do. 或者,正如浏览器知道它在哪个网站上一样,只需Logo/image1.jpg

All you need is 所有你需要的是

Image11.ImageUrl = "Logo/" & img_name

您好,请按照以下步骤更改您的代码

 logo_path = Server.MapPath("/Logo") & "/" & img_name

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

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