图像未显示MVC-5 [英] Image is not showing MVC-5
本文介绍了图像未显示MVC-5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
**In browser view source:**
<img src="D:\VS 2013\BusinessClass2\BusinessClass2\Img\butterfly(Butterfly).jpg" />
but image is not showing at all.
**In Controller:**
string name = Path.GetFileNameWithoutExtension(fileName); //getting file name without extension
string myfile = name + "(" + employee.Emp_name + ")" + ext; // append Employee name
var path = Path.Combine(Server.MapPath("~/Img"), myfile);
我的尝试:
**在视图中:**
< img src =@ Html.Raw(item.Emp_image)/>
**也尝试过:**
< img src =@ Url.Content(item.Emp_image)/>
What I have tried:
**In View:**
<img src="@Html.Raw(item.Emp_image)"/>
**also tried:**
<img src="@Url.Content(item.Emp_image)"/>
推荐答案
如果您的图片没有显示它因为它不存在。确保文件D:\ VS 2013 \ BusinessClass2 \ BusinessClass2 \Img \butterfly(Butterfly).jpg存在,并且您的Web应用程序对该文件/目录具有适当的安全权限。
If your image is not showing its because it does not exist. Make sure the file D:\VS 2013\BusinessClass2\BusinessClass2\Img\butterfly(Butterfly).jpg exists and that your web application has proper security rights to that file/directory.
这篇关于图像未显示MVC-5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文