asp.net-mvc MVC 3 - _Layout.cshtml。向网站添加徽标

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10632544/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 01:56:58  来源:igfitidea点击:

MVC 3 - _Layout.cshtml. Add a logo to the site

asp.net-mvcasp.net-mvc-3

提问by Kulpemovitz

I'm new to MVC 3, I'm trying to add an Image to the _Layout.cshtml file. I tried

我是 MVC 3 的新手,我正在尝试将图像添加到 _Layout.cshtml 文件中。我试过

<img runat="server" id="img_logo" alt="Logo" src="Content/Images/mailworks.png" />

no success. The logo only appear on some views. on others views for some reason the image is supposed to be in some other location - found it using firebug.

没有成功。徽标仅出现在某些视图中。出于某种原因,在其他视图中,图像应该位于其他位置 - 使用 firebug 找到它。

回答by Aleksei Pugachev

Try this:

尝试这个:

<img id="img_logo" alt="Logo" src="@Url.Content("~/Content/Images/mailworks.png")" />

回答by serge.karalenka

Use this:

用这个:

<img src="@Url.Content("~/Content/Images/mailworks.png")"...