如何使用c#在网页上显示本地文件中的图像?

时间:2017-05-30 16:50:42

标签: c# html asp.net webforms

我正在尝试使用文件中的位置显示图像。目前我将图像存储在我的Web应用程序的内容文件夹中,但我不知道如何在那里访问它或在页面本身上显示它。这就是我现在所拥有的。

    Image image = Image.FromFile(@"~\Content\img\toendra.JPG");

1 个答案:

答案 0 :(得分:0)

在Web窗体中,我们使用Image control来显示图像。把它放在你的标记中:

<asp:Image runat="server" ImageUrl="~/Content/img/toendra.JPG" />