htmlasp.netservertag

ASP page not retrieving import files


On a newly created website, based on an existing site, the @import is not locating the CSS files. I am just attempting to pull in the CSS files for a simple Hello World in order to make sure that this first step is functioning.

The HTML heading code:

<head id="Head1" runat="server">
    <title>Company Name - Hello World</title>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />

    <style media="all" type="text/css">
        @import '<%# ResolveUrl("~/layout/HelloWorld.css")%>';
    </style>

</head>

Using Chrome, the Developer Tools displays the following:

<html>
<head id="Head1"><title>
    Company Name - Hello World
</title><meta http-equiv="X-UA-Compatible" content="IE=Edge" /><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />

    <style media="all" type="text/css">
        @import '';
    </style>

</head>

The folder structure for the site contains the following:


I have done a side by side comparison of the IIS settings for a working ASP site and the Hello World site, and not differences have been found. I am at a loss as to why the @import is displaying as an empty string.

Any wisdom as to how to resolve this is greatly appreciated.


Solution

  • It should be:

    <link rel="stylesheet" type="text/css" href="~/layout/HelloWorld.css" />