<p>Use this area to provide additional information.</p>
<a href="@Url.Action("ImagePath1", new { id="1" })">下载</a>
<img src="@Url.Action("ImagePath1", new { id="1" })" />
<img src="@Url.Action("ImagePath", new { id="1" })" />
<img src="@Url.Action("ImageContent", new { id="1" })" />
<img src="@Url.Action("ImageStream", new { id="1" })" />
public ActionResult ImagePath(string id)
{
string path = Server.MapPath("/images/" + id + ".jpeg");
return File(path, "image/jpeg");
}
public ActionResult ImagePath1(string id)
{
string path = Server.MapPath("/images/" + id + ".jpeg");
return File(path, "image/jpeg", "下载");
}
public ActionResult ImageContent(string id)
{
string path = Server.MapPath("/images/" + id + ".jpeg");
byte[] heByte = null;
using (FileStream fsRead = new FileStream(path, FileMode.Open, FileAccess.Read))
{
int fsLen = (int)fsRead.Length;
heByte = new byte[fsLen];
int r = fsRead.Read(heByte, 0, heByte.Length);
}
return File(heByte, "image/jpeg");
}
public ActionResult ImageStream(string id)
{
string path = Server.MapPath("/images/" + id + ".jpeg");
FileStream fsRead = new FileStream(path, FileMode.Open, FileAccess.Read);
return File(fsRead, "image/jpeg");
}