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);
    }

Upvotes: 0

Views: 529

Answers (3)

manthan
manthan

Reputation: 132

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>

Upvotes: 0

Vaduganathan
Vaduganathan

Reputation: 11

Try this:

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

Upvotes: 0

jaabh
jaabh

Reputation: 1004

Create a folder in wwwroot named images. Place the string there, then in the view

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

Upvotes: 1

Related Questions