0

I want to load a path to picture from config file in order to show different pictures on different webapps.

Here I have

<add key="logoFileName" value="~/images/logo.png" />

And I want to use it like

<img src="@System.Configuration.ConfigurationManager.AppSettings["logoFileName"]" height="65" />

But .net only show "~/images/logo.png", wich must be interpreted by .net as well.

How to perform this in order to see the logo?

clement
  • 4,204
  • 10
  • 65
  • 133
  • 1
    The tilde must be a literal in your view in order for Razor to translate it to a relative path. Use `Url.Content()` for strings that are determined at runtime, see duplicate. – CodeCaster Nov 18 '16 at 16:07

1 Answers1

0

I've finally solve this by making the path to the folder and then append the filename:

<add key="logoFileName" value="logo.png" />

<img src="~/images/@System.Configuration.ConfigurationManager.AppSettings["logoFileName"]" height="65" />
clement
  • 4,204
  • 10
  • 65
  • 133