【问题标题】:Entity Image not showing up实体图像未显示
【发布时间】:2021-08-02 09:29:48
【问题描述】:

大家好!我对我的代码感到困扰,请帮忙。在我的项目中添加上传功能后,上传的照片没有显示出来。我确信上传工作正常,因为照片已传输到图片目录并且文件路径存储到数据库中。我正在使用Entity进行开发,我上传的照片大小小于1MB。

 @foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.branchid)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.date)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.validid)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.completeName)
        </td>
        <td>
            <img src="@Html.DisplayFor(modelItem => item.picture)" height="100" width="100" />
            @*<img src="@Url.Content(item.picture)" alt="Alternate Text" />*@
        </td>
        <td>
            @Html.ActionLink("Edit", "Edit", new { id=item.id }) |
            @Html.ActionLink("Details", "Details", new { id=item.id }) |
            @Html.ActionLink("Delete", "Delete", new { id=item.id })
        </td>
    </tr>
}

</table>
<img src="~/Image/couple213129435.jpg" alt="Alternate Text" />

如您所见,我尝试使用 @Url.Content(item.picture) 但返回“值不能为空或空”错误。

我还尝试将存储在数据库中的文件路径放在“img”标签内,以检查路径是否没有损坏,并且浏览器上显示的不是图像。谢谢

【问题讨论】:

    标签: .net model-view-controller upload entity


    【解决方案1】:

    它现在可以工作了,我只是删除了路径中的“~”。

    【讨论】:

      猜你喜欢
      • 2017-01-27
      • 2021-10-12
      • 2017-07-08
      • 1970-01-01
      • 2016-10-19
      • 2016-11-30
      • 2023-01-15
      • 1970-01-01
      • 2012-07-05
      相关资源
      最近更新 更多