ASP.NET page is not loading CSS styles
Add runat="server"
to the head attribute and also ensure the link targets the root as in ("~/path to css")
<head runat="server">
<title>Page Title Here</title>
<link href="~/css/main.css" rel="stylesheet" type="text/css" />
<asp:ContentPlaceHolder ID="HeadContent" runat="server" />
</head>
This works for me in my master pages:
<asp:content ID="xContent" ContentPlaceHolderID="headContent" runat="server">
<link rel="stylesheet" type="text/css" href="<%=Request.ApplicationPath%>Folder/Folder/Filename.css" />
</asp:Content>'
The stylesheets included in your master page are using relative paths.
Specify your stylesheet links with runat=server
and prefix them with the virtual web root path (~
):
<link href="~/Styles/style.css" rel="stylesheet" type="text/css" media="screen" runat="server" />
OR:
<link href="/Styles/style.css" rel="stylesheet" type="text/css" media="screen" runat="server" />
But keep in mind that the first option is recommended. The second will not work when you publish your site in a virtual directory.
After last comment...
The image URL's in CSSs should be updated as well, in order to not use relative paths or do any path traversal (../).
background: #fff url(images/img01.jpg) repeat-x left top;
For this option you will need to move the images folder inside the Styles folder (it's a good practice to do so).
Final update:
Looks like that the head
element also needs to be runat=server
in order for ASP.NET relative paths (~) to work within link
elements with runat=server
.