ASP.NET MVC 5图像/脚本未在运行时加载

时间:2016-01-10 18:17:43

标签: asp.net asp.net-mvc

我开始搞乱ASP.NET MVC 5(到目前为止一直很好)。 ASP.NET MVC看起来非常酷,我渴望了解更多。我一直在尝试为测试应用程序设置几个网页(视图)。我觉得奇怪的是,尽管我们的图像存在于正确的文件夹中,但它们仍然无法加载。我也注意到我的css脚本似乎不起作用。这是我的图像的代码:

<div id="Features">
<div class="row">
    <div class="col-md-4" align="center">
        <h2>Get Your Grocery List</h2>
        <img src="~/Images/grocerylist.jpg" width="200" height="200" id="mainImage"/>
        <p>With this application, you can rest assured you wont need to spend minutes drafting your grocery list - this application will generate a grocery list for you on the fly!</p>
    </div>
    <div class="col-md-4" align="center">
        <h2>Compare Grocery With Shops</h2>
        <img src="~/Images/CompareConsumerPricing.png" width="200" height="200" id="ConsumerPricing"/>
        <p>We know that different shops will have different prices. This application lets you list several shops and compare pricing - this means you will get the upper hand (bill shock will be a thing of the past)</p>
    </div>
    <div class="col-md-4">

当我运行我的Web应用程序时,我得到了这个输出:

enter image description here

我在Visual Studio 2015上使用IIS来测试所有内容。我必须在Web配置文件中添加一些内容吗?我已经检查过,图片和脚本确实存在于引用的URL中。

编辑:这是我的解决方案资源管理器(在Visual Studio 2015上):

enter image description here

1 个答案:

答案 0 :(得分:-1)

尝试:

src="@Url.Content("~/Images/grocerylist.jpg")"