0

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

3 Answers 3

1

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

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

Sign up to request clarification or add additional context in comments.

4 Comments

Src is not a member of Image. Can you help me with this?
What version of asp.net? Maybe that is a problem. Here is a short article learn.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/…
I have an asp.net core project. In it, I have a model with a property public string ImagePath {get;set;}. The value of that property is something like "/images/ImageName.png". Then in my view I have <img src="@Html.DisplayFor(model => model.ImagePath)" />
I'm using a if statement to display a correct image.
0

Try this:

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

1 Comment

AppContext.BaseDirectory gave me an object reference error.
0

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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.