简体   繁体   中英

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:

  • HelloWorld -> the root
  • -- layout (folder)
  • -- pages (folder)
  • index.aspx

  • The code is a cut and paste from the a functioning ASP site.
  • In the developer tools under the Sources option, there are no folder paths being displayed.
  • The CSS file has been verified to exist in the layout folder.
  • The web page displays, but without the CSS formatting.
  • No error messages are generating when displaying a simple one line web page .

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.

它应该是:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM