tags:

views:

89

answers:

2

I have developed some ASP.NET server controls which include their own javascript and css files. A lot of these controls use jQuery extensions which, as you know, often include their own css files.

I'm using Telerik's RadScript manager which combines the javascript like a boss. However, I'm using the AjaxToolkit's ClientCssResource attribute to include the css files in my server controls, and I have noticed that the CSS files are not getting combined at all. My pages have 10-15 WebResource.axd requests for css files for my server controls.

Everything I find only is about combining javascript, and nothing tells me how I can combine the CSS files. Does anyone know if there is a way to combine the CSS dynamically (I don't want to manually combine as each page might use a different subset of the server controls)?

+1  A: 

You will need to write your own IHttpHandler for this. There is a working example at Combine Multiple JavaScript and CSS Files and Remove Overheads.

Giorgi
This only combines static CSS files which must be hardcoded in the web.config. I have server controls adding CSS scripts which the page doesn't know about.
tster
A: 

Optimize WebResource.axd and ScriptResource.axd

That also compresses them.

It's important to make sure it doesn't become an extra vector of attack for the padding oracle in the wild. Make sure that if it receives any garbage / resource not found it fails with an exception and the ms workaround is implemented.

eglasius