简体   繁体   中英

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. 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 . 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. It will help you if it is permission related issue.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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