0
我遇到了一个问题,显示的图像不在应用程序文件夹内,而是在C:\ tmp \ Somename \ somepic.jpg我一直在寻找和尝试,徒劳无功。问题不在应用程序文件夹中加载图像图像
我有什么至今(我认为与此有关的问题)是: 在控制器
public ActionResult Edit(int? id)
{
if (id.HasValue)
{
var model = GetItems(id.Value);
ViewBag.Images = Directory.GetFiles(WebConfigurationManager.AppSettings["itemPath"] + model.ContentId.ToString().Substring(0, 3) + "\\", model.ContentId + "*.jpg");
return View(model);
}
return View("Notfound", "Home");
}
,并在视图
<div class="row">
@foreach (var item in ViewBag.Images)
{
<img src="@Url.Content(item)" alt="hello"/>
}
任何帮助,将不胜感激。
你能给我一步一步该怎么做? – Siemsen
您是否在引用WebDev.WebServer40.exe进程,因为这是在我的帐户下。 – Siemsen
这取决于你的设置,可能是......你能否澄清问题。我最初理解你不能访问文件(用户权限问题)。你的意思是你实际上可以访问它们,但是它们没有显示在浏览器中? 'img'标签的'src'属性中显示的URL是什么? –