【问题标题】:Why image src is showing twice localhost and port?为什么图像 src 显示两次本地主机和端口?
【发布时间】:2022-11-16 15:53:56
【问题描述】:

我有从服务器返回的图像吗?

路径是 https:\localhost:7229\Images\sample-clouds-400x300.jpg

当我把它放在 src 中时,它进入网络

https:\localhost:7229\https:\localhost:7229\Images\sample-clouds-400x300.jpg

任何原因 ?

【问题讨论】:

    标签: html


    【解决方案1】:

    这来自您的错字:

    https:localhost:7229Imagessample-clouds-400x300.jpg
          î There should be 2 
    

    由于只使用了一个斜杠,路径被视为相对路径,然后浏览器通过添加当前页面的 url 将其转换为绝对路径。

    【讨论】:

      【解决方案2】:

      你能提供一些代码吗?您调用什么来检索路径以及如何将路径插入页面?

      【讨论】:

      • foreach (var user in users) { user.ImagePath = "https:\"+ Request.Host.Value +"\"+ "Images" + "\" +user.ImagePath;然后在视图中 <td>@item.ImagePath</td>
      猜你喜欢
      • 1970-01-01
      • 2010-12-29
      • 1970-01-01
      • 1970-01-01
      • 2021-08-22
      • 1970-01-01
      • 2016-04-12
      • 1970-01-01
      • 2020-03-06
      相关资源
      最近更新 更多