开发者

Css ignoring everything after the first class

I'm using this guide to create a HTTPHandler that combines script and css files to deliver them as one request each.

Basically it reads a bunch of .css files into a byte array and then response.writes the bytes to the client with a content-type of text/css(or text/ja开发者_如何学编程vascript)

When using FireBug it appears that the CSS comes through fine...it is all there. However, the browser itself will is only rendering CSS that is in the first file used in the combining action.

Example:

File1.css: body { font-size: 20px; } h1 { color: red; }

File2.css: div { border: solid 1px black; }

All the CSS is visible via Firebug in the CSS tab...however the class from File2.css is not actually applied to divs on the page. If I flip the order of the files, divs get a border, but nothing from File1.css gets applied.

Javascript files work totally fine, but the CSS has me totally stumped!

EDIT TO SHOW CSS COPIED OUT OF FIREBUG

body {
font-size:22px;
}
h1 {
color:Red;
text-decoration:underline;
}
div {
border:1px solid black;
}

HERE IT IS FROM THE NET TAB, THE ACTUAL RESPONSE GENERATED

ParamsHeadersPostPutResponseCacheHTML
Response Headersview source
Server  ASP.NET Development Server/9.0.0.0
Date    Mon, 29 Nov 2010 01:10:26 GMT
X-AspNet-Version    2.0.50727
Transfer-Encoding   chunked
Cache-Control   public, must-revalidate, proxy-revalidate, max-age=259200
Expires Thu, 02 Dec 2010 01:10:26 GMT
Content-Type    text/css
Connection  Close
Request Headersview source
Host    localhost:49598
User-Agent  Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12
Accept  text/css,*/*;q=0.1
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip,deflate
Accept-Charset  ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive  115
Connection  keep-alive
Referer http://localhost:49598/



body 
{
    font-size: 22px;

}

h1 
{
    color: Red;
    text-decoration: underline;
}div 
{
    border: solid 1px black;
}

New development. If I create the .css files in notepad everything works fine. Does VS2008 add something unseen to the file when creating a Stylesheet file?

FIDDLER TEXTVIEW (Dunno where the extra characters came from. Interesting.

9a


body 
{
    font-size: 22px;

}

h1 
{
    color: Red;
    text-decoration: underline;
}div 
{
    border: solid 1px black;
}
0


In the GetFileBytes change the following lines

    byte[] bytes = File.ReadAllBytes(physicalPath);
    // TODO: Convert unicode files to specified encoding. For now, assuming
    // files are either ASCII or UTF8
    return bytes;

To

    string content = File.ReadAllText(physicalPath, encoding);
    return encoding.GetBytes(content);


I'm not sure what's wrong; if Firebug's CSS tab sees the CSS, it ought to render.

Try clearing the cache (Ctrl+F5) and restarting Firefox.

Try adding a newline between the CSS files on the server; there's a slight possibility that that might help.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜