mvc之文件下载

 

首先你要有四张图片,也就是数组中的数

public ActionResult Index()//创建视图
{
ViewBag.list =new int[] { 5, 6, 7,8 };

return View();
}
public ActionResult Get(int? id)
{
FilePathResult fpr = new FilePathResult(Server.MapPath("~/Content/imgs/"+id+".jpg"),"imgs/jpeg");
return fpr;
}

------------------Index:

@{

foreach (int item in ViewBag.list)
{
<li>@Html.ActionLink("sss" + item + "sss", "Get", "Home", new { id = item }, null) </li>
}
}

posted @ 2016-10-20 22:26  路边有一棵草  阅读(122)  评论(0编辑  收藏  举报