简体   繁体   English

ASP.NET C# Web 应用程序中未显示图像

[英]Image Not Displaying in ASP.NET C# Web App

I have a png image in my Bin folder and it's net displaying in my web app.我的 Bin 文件夹中有一个 png 图像,它在我的 web 应用程序中显示。 Can anyone help me with this?谁能帮我这个?

    if (Calculation_Type.SelectedItem.Value == "1")
    {
        Generate_Flexible_ACN_Straight_Chart(ref vehicle);
        Legend.ImageUrl = "~/Bin/Flexible_Pavement_Subgrade_Strength.png";
    }
    else if (Calculation_Type.SelectedItem.Value == "2")
    {
        Generate_Flexible_ACR_Straight_Chart(ref vehicle);
    }

Create a folder in wwwroot named images .wwwroot中创建一个名为images的文件夹。 Place the string there, then in the view将字符串放在那里,然后在视图中

<img src="~/images/imageName.png />

Try this:尝试这个:

Legend.ImageUrl = Path.Combine(AppContext.BaseDirectory, "Flexible_Pavement_Subgrade_Strength.png");

put following code in web.config file.将以下代码放入 web.config 文件中。 It will help you if it is permission related issue.如果是与权限相关的问题,它将为您提供帮助。

<location path="Image Path">
<system.web>
<authorization>
<allow user="*"/>
</authorization>
</system.web>
</location>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM