1

I have this variable defined in my web.config file :

<appSettings>
    <add key ="version" value="123"/>
</appSettings>

and I am using it in my aspx pages' headers without problem:

<link rel="stylesheet" type="text/css" href="../css/style.css?<%= ConfigurationManager.AppSettings["version"] %>"/>

But this doesn't seem to work in a regular HTML page. What is the correct way of using a web.config variable in straight HTML ?

Jelly Ama
  • 6,701
  • 3
  • 20
  • 23

1 Answers1

1

Server code (for instance what you have in the <%%>) can't be executed on static pages.

You need to append this manually in your static pages, or convert them to dynamic pages (.aspx).

<%%> stands for:

<script runat="server"></script>

In a static page which is not routed through the ASP.NET engine, this will not do anything and will not get converted to server code.

Oded
  • 489,969
  • 99
  • 883
  • 1,009
  • can you explain how to do that. I have my external resources referenced in Site.Master. It works perfect with .js files: , but it doesn't work with .css. – Caner Akdeniz Dec 17 '13 at 16:25
  • @CanerAkdeniz - How do you mean with `.css`? In an `.aspx` page linking to one? Or **inside** a `.css` file? If the latter - well, `.css` files are static - they do not execute. If so, I suggest looking at LESS/SASS. – Oded Dec 17 '13 at 16:39