Question

I am not sure why when I place the web app on the MS server 2008 R2 that it is not reading the style sheets on any pages.

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<link href="/styles/StyleSheet1.css" type="text/css" rel="stylesheet" />

The masterpage has no styles on it or anything on it except the ToolkitScriptManager. I placed it there for future use if needed.
Viewing the source shows the style links there and if I take a link and past it in the url the style sheet appears, so yes, it's there on the server.

    http://serverName/WebAppName/styles/StyleSheet1.css



This occurs in all browsers.
The styles are being read in Visual Studio 2010 when debugging.
I tried placing a tilde (~) in front of the reference
link href="~/styles.....
This had no effect.
I tried removing the first forward slash even though I knew this was wrong.
I have been through the server configurations but with no luck.
I there a configuration in the server I am missing? It's been about two years since I had to do any configurations but it is nice to have access to the servers once again.

Thanks for any responses...

Was it helpful?

Solution

After doing a bit of research I found the answer and wanted to post it for a reference to others.
Yes, the link to the css file was broken after testing with Firebug.

Why was it broken? It was from the server.

When creating a directory in IIS for a new site, there are some choices.
I made the choice to create a new virtual directory under the Default Web Site directory.
Old habits die hard from my .Net 1.0 days.
This means the page was looking for the css folder in the wrong place and the href needed to be changed to href="styles/... without the first forward slash.
But when there are a LOT of pages to make changes, this is not a good idea.
What I did and should have done in the first place was create a NEW web site under the Sites folder in IIS. This way it's not a new Virtual Directory and the relative paths throughout the site are now correct.

I hope this post helps someone else in the future.
Thanks for all the replies and suggestions!!!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top