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

页面:

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

后台代码:

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

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

部分截图:

MVC @Url.Action 小示例  效果图:MVC @Url.Action 小示例

 

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

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-17
  • 2021-06-09
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-29
  • 2021-11-07
  • 2022-12-23
相关资源
相似解决方案