在MVC视图上显示图像 [英] Image display on MVC view

查看:235
本文介绍了在MVC视图上显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在cshtml文件上显示图像. 垃圾邮件过滤器阻止我键入图像的HTML.但是,源设置为

I am trying to display image on the cshtml file. The spam filter prevents me from typing the HTML for image. However the source is set to

src= "@Html.Encode(Model.PictureLocation)"  alt="IMAGES"

在视图源中显示为

src= "C:\Documents and Settings\xxx\My Documents\Visual Studio 2010\Projects\MVC\TIQC_ServerInterface\TIQC_ServerInterface\uploads\FileUpload12011_03_02_11_49_22.jpg"  alt="IMAGES"

图片位于src路径中提到的位置.

The image is present in the location mentioned in the src path.

执行时,页面未显示图像.让我们知道这里是否有问题?

On execution, the page is not displaying the images. Let us know if anything wrong here?

推荐答案

您指定了客户端计算机上不存在的绝对路径.尝试这样:

You have specified an absolute path which doesn't exist on the client computer. Try like this:

<img src= "@Url.Content("~/uploads/FileUpload12011_03_02_11_49_22.jpg")" alt="IMAGES" />

或者如果您的模型变量包含〜/uploads/FileUpload12011_03_02_11_49_22.jpg",则可以:

or if your model variable contains "~/uploads/FileUpload12011_03_02_11_49_22.jpg" you could:

<img src= "@Url.Content(Model.PictureLocation)" alt="IMAGES" />

这篇关于在MVC视图上显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆