Search code examples
c#htmlcssrunatserver

runat="server" at html Head tag causing c# embedded code blocks not convert to client side code


When I added runat="server" at head tag and some css href with <%= WebAppInstance %> value. It turn out the <%= WebAppInstance %> is not convert to client-side code. I hope the code below can clarify my question.

C#.Net code:

<head id="Head1" runat="server">
    <meta http-equiv="X-UA-Compatible" content="IE=9" />
    <title>Testing</title>
    <link rel="stylesheet" href="<%= WebAppInstance %>/bucket/css/bootstrap.min.css" />
</head>

HTML code as image shown:

Html code with highlighted problem Could you tell me what is going on? Thank you!


Solution

  • Kindly remove the space character after <%=. So that you code becomes:

    <%=WebAppInstance %>
    

    Else use the full version:

    <% Response.Write(WebAppInstance); %>