Code Render Blocks does not work inside HEAD server controls

I had a ASP.NET page with HEAD as server control similar to the following:

      <HEAD runat = “server”>
            <%this.RenderHeadItems();%>
            <link rel=”stylesheet” type=”text/css” href=”WebjetStyles.css?v=<%=AssemblyVersionNumber()%>“>
      </HEAD>
The first server function was called and executed successfully, but the second Code Render Blocks located inside a parameter of link element, wasn’t considered as server code and literally was copied to client HTML as &lt;%=AssemblyVersionNumber()%&gt;
Only when I removed runat = “server” attribute in HEAD element, the second Code Render Block was executed and rendered to HTML correctly.
I haven’t find any documented limitations regarding Embedded Code Render Blocks in MSDN
However other people noticed similar problems with HEAD runat = “server”.
And in some scenarios you have to use HEAD runat = “server”.

I am calling AssemblyVersionNumber() to ensure that browser will load the latest version of CSS file.


Previously I posted about other  unexpected behaviour of controls with runat = “server”:
asp:PlaceHolder can be put within html table, if it is not runat=”server”
See my post Insert CSS link with updatable version number in URL how I resolved the issue.