将图像添加到ASP.NET MVC项目。

huangapple go评论75阅读模式
英文:

Add image to ASP.NET MVC project

问题

如何将现有图像添加到我的ASP.NET MVC项目中?当我直接从Google复制URL时,图像未显示,但当我将其保存到我的计算机,然后尝试添加它时,它不起作用。

我已经尝试过这段代码

<i>
    <img src="C:\filename.txt\WebApplication3\WebApplication3\Images\cars.jpg" class="card-img" alt="..." >
</i>
英文:

How can I add an existing image to my ASP.NET MVC project? The image is not being displayed, it works fine when I copy the url directly from Google, but when I save it to my PC and then try to add it, it doesn't work.

I've tried this code

&lt;i&gt; 
    &lt;img src=&quot;C:\filename.txt\WebApplication3\WebApplication3\Images\cars.jpg&quot; class=&quot;card-img&quot; alt=&quot;...&quot; &gt; 
&lt;/i&gt;

答案1

得分: 1

我找到了我需要的答案,"将您的图像移到wwwroot文件夹并使用~/cars.jpg,因为ASP.NET Core仅从wwwroot文件夹获取静态文件。谢谢!

英文:

i found the answer i needed, "Move your image into wwwroot folder and use ~/cars.jpg, because ASP.NET Core gets static files from only wwwroot folder. Thanks!

huangapple
  • 本文由 发表于 2023年3月3日 23:59:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/75629305.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定