Nate Pet
Nate Pet

Reputation: 46322

image does not show up when when calling from @Html.Action

I have an odd issue. I simplified what I my issue is.

Within my _Layout.cshtml, I have the following code. The image shows up fine.

<img src="~/Content/images/draw.png" />

Instead, if I replace it with the following:

 @Html.Action("RetrieveLogo", "Info")

And do the following:

    public string RetreiveLogo()
    {
        return $"<img src=\"~/Content/images/draw.png\"/>";
    }

The image does not show up. I see it hitting RetreiveLogo and returning the value. It does not show the image though.

As mentioned, what I have above is simplified as my content is more dynamic than this. Any assistance would be appreciated.

Upvotes: 0

Views: 32

Answers (1)

Adlorem
Adlorem

Reputation: 1517

You could try something like this:

public ActionResult RetreiveLogo()
{
    return PartialView("<img src=\"~/Content/images/draw.png\"/>");
}

Upvotes: 1

Related Questions