Mike Hofer
Mike Hofer

Reputation: 17022

Why does Visual Studio WebDev Not Load my StyleSheet?

So here's an interesting conundrum.

I have a page, default.aspx. It has a LINK tag to a stylesheet, located in the CSS subfolder:

<link type="text/css" rel="Stylesheet" href="Css/Logon.css" media="all" />

The folder structure is as follows:

[Root]
    [CSS]
    [Images]
        [Logon]

No big surprises. (Our default.aspx page is our logon page. Again, no big surprises.)

Here's the problem. If you launch the page in IIS, the page renders beautifully. CSS loads, fonts appear, everything is positioned appropriately, and lions are laying down with lambs.

If you view the page in WebDev, the stylesheet isn't loaded. Since it specifies all the images, fonts, and positioning, everything is black on white, in Times New Roman, slammed left against the window border. Dogs are chasing cats in circles and causing traffic accidents. Chaos ensues.

Why? How do I fix it? What information do I need to provide to reach a happy conclusion?

P.S. I am aware of the URL differences between running it in IIS and Webdev, but the differences don't seem to make much sense to me, due to one simple fact: the path to the style sheet is relative to the location of the default.aspx page. The stylesheet isn't being loaded at all. I can see this because there's no font styling at all.

Upvotes: 0

Views: 385

Answers (2)

Mike Hofer
Mike Hofer

Reputation: 17022

We eventually discovered the cause of this problem using Fiddler: HTTP 401 (Unauthorized). A little more research uncovered that we needed to add explicit <location/> entries for the stylesheet, and all the images it referenced, to our web.config file.

Upvotes: 0

D Maxim
D Maxim

Reputation: 61

My recommendation would be to use Firefox to load the page. With the Firebug add-on installed you can view the requests for the CSS files in the Net panel. This will allow you to at least see the path that is being used for the CSS file.

If you have not used the network monitoring feature in Firebug before you may want to go here:

http://getfirebug.com/network

Upvotes: 1

Related Questions