MVC @Url.Action 小示例

功能说明:从Action获取图片路径,页面显示图片

页面:

<img src="@Url.Action("ImagePath", new { id="1"})"  />

后台代码:

public ActionResult ImagePath(string id)
{
string path = Server.MapPath("/Content/Images/" + id + ".jpg");

return File(path, "image/png");
}

部分截图:

  效果图:

 

以前没用过Url.Action 函数,今天偶遇,记录一下;希望能帮助到你!

 

posted @ 2015-12-21 17:01  飙速  阅读(1631)  评论(1编辑  收藏  举报