Asp.net mvc 4 带“的图像错误”~&引用;符号

Asp.net mvc 4 带“的图像错误”~&引用;符号,asp.net-mvc-4,Asp.net Mvc 4,我的页面中的图像有问题。在我的数据库中,我提到了如下图像路径: "/images/smallimages/sandal1.png " 它工作正常,并在本地主机上显示我的视图中的图像,但将代码上载到服务器后,图像不会显示。是否需要在图像URL中放置波浪号(~)符号?。我正在绑定图像路径,如下所示: <a href="@Html.DisplayFor(m=>m.larImagePath1)" class="MagicZoom" id="Zoomer" rel="selectors-ef

我的页面中的图像有问题。在我的数据库中,我提到了如下图像路径:

"/images/smallimages/sandal1.png "
它工作正常,并在本地主机上显示我的视图中的图像,但将代码上载到服务器后,图像不会显示。是否需要在图像URL中放置波浪号(~)符号?。我正在绑定图像路径,如下所示:

<a href="@Html.DisplayFor(m=>m.larImagePath1)" class="MagicZoom" id="Zoomer" rel="selectors-effect-speed:100">
    <img src="@Html.DisplayFor(m=>m.medImagePath1)" /></a><br/>
<!-- selector with own title -->
<a href="@Html.DisplayFor(m=>m.larImagePath1)" rel="zoom-id:Zoomer;" rev="@Html.DisplayFor(m=>m.medImagePath1)">
    <img src="@Html.DisplayFor(m=>m.smaImagePath1)"/></a>
<!-- selector without title and with own zoom window size -->
<a href="@Html.DisplayFor(m=>m.larImagePath2)" rel="zoom-id:Zoomer;selectors-effect-speed: 200" rev="@Html.DisplayFor(m=>m.medImagePath2)">
    <img src="@Html.DisplayFor(m=>m.smaImagePath2)"/></a>


您应该为图像Url使用
Url.Content
帮助程序,如下所示:

<img src='@Url.Content("~" + Model.smaImagePath1)' />

我修正了我自己的问题,并且用渐近法给出了很好的解决方案。