c# - Image isn't displaying
问题描述
I have a div property inside a form where I want to display an image.
But I can't manage to fix it. I get an HTTP ERROR 404.
My solution tree looks like:
MyProject
--Controllers
--img
----Logo.jpg
--Models
--Views
----Home
------Login.cshtml
Part of Login.cshtml, where I have the img property.
<div class="split left">
<div class="centered">
<img src="~/img/Logo.jpg">
</div>
</div>
What I'm a doing wrong?
Thanks in advance for any help.
解决方案
您不能在img
标记中使用波浪号 (~) 客户端,因为它无法解析根目录。
您需要使用页面中的相对路径:
<img src="../img/Logo.jpg">
如果要使用波浪号,则需要使用服务器端标记。
推荐阅读
- python - Discord.py 超时命令
- python - 使用弹性搜索中的另一个索引检查一个索引中的python值并创建一个新数据库
- postgresql - Postgres 如何计算 current_timestamp?
- spring-boot - 下载大型 zip 文件时出现异常 ClientAbortException: java.io.IOException
- .net - MapsterMapper 从接口映射到内部设置器属性
- map-force - 如何将值映射表中的值映射到异常?
- python - 数独算法生成重复值
- charts - 如何在 Google 条形图中分配条形颜色
- angular - 如何在Angular Kendo UI Treelist中从父行展开所有子行
- maven - Mac OS 上 Maven 中的 Java 版本管理