1 SomeNewKid |
Saturday, July 10, 2004 @ 3:17 AM
Excellent article, Milan, particularly as it touches on some less-well-known ASP.NET abilities such as XML serialization and custom config sections.
I once came up with a quick-and-dirty method of adding variables to stylesheets. However, your method is indeed much sweeter.
Keep up the great work!
2 Ryan Farley |
Monday, July 12, 2004 @ 9:40 PM
Great stuff (as always) Milan. Rory Blyth did something similar a while back. His approach was not as flexible as yours but still another example for your readers to look at.
http://neopoleon.com/blog/posts/4069.aspx
-Ryan
3 Bobby |
Friday, August 06, 2004 @ 2:22 PM
besides the fact that his downloadable project doesnt work, it would almost sound like a cool trick
4 Milan Negovan |
Friday, August 06, 2004 @ 2:34 PM
Bobby, did you remember to register the HttpModule in web.config?
5 Bobby |
Monday, August 09, 2004 @ 7:06 AM
im using the same web.config file.. this is the error i get:
File or assembly name DynamicCSS, or one of its dependencies, was not found.
Source Error:
Line 8:
Line 9:
Line 10:
Line 11: Line 12:
6 Bobby |
Monday, August 09, 2004 @ 7:07 AM
well, it didnt show the code above.. but it is the lines in the config fo rthe httpHandlers section
7 no fun |
Thursday, August 19, 2004 @ 3:22 AM
Another (easier?) solution could be to just create a file, dynamic.css.aspx, and change the Content-type.
private void Page_Init(object sender, System.EventArgs e)
{
this.ContentType = "text/css";
}
You could even include something like
<%@ OutputCache Duration="86400" VaryByParam="None" Location="ServerAndClient" %>
...and in the file you might have
const string BODY_COLOR = "black";
...
body {
color: [%=BODY_COLOR%]; // couldn't post tag brackets...
}
8 James |
Wednesday, October 13, 2004 @ 7:37 AM
no fun > I use it every day and even if the first solution is technically interesting, I find the latter easier (few code, no server configuration).
Even I havn't got any "aspx.cs" file, everything is in the "aspx" file.
It helps me to create dynamic stylesheets "on the fly", and does not confuse me with multiple files, because most things are common from one browser to another, except details like font size (mac).
< link rel="stylesheet" href="stylesheet.aspx" >
and that's all for the caller !
9 Jeremy |
Friday, February 03, 2006 @ 2:47 PM
Nice article. Seems to be extremely flexible, but I'm wondering if it is completely so. With the variables stuck in the Web.Config, can you use seperate themes for different domains using the same content?
What if you have an application that is using multiple color schemes based on domain names? How can you adjust for having a green-cyan theme for one domain, an orange-gray theme for another domain and a tan-maroon theme for another domain?
Can you just specify different style sheets to take in the variables that you create in the Web.config? Or would you have to change the way you are specifying the CSS vars?
10 Milan Negovan |
Tuesday, February 07, 2006 @ 7:39 AM
Jeremy, I haven't dealt with master pages and skins in 2.0 yet. What I've outlined here works for one site because I wrote it when 2.0 wasn't around. I think it's very feasible to implement this on a skin-by-skin basis, though.
11 sharad singh |
Tuesday, February 21, 2006 @ 12:43 AM
Hi all
This Article is good, but this is not sufficient for me. I'm new to ASP.NET. i understood the code but i didn't understand how to make a request to the CSS from your .aspx file. so i put a link to that CSS in HTML of my page. yeah that started to work, but when you change your color next time, it doesn't change, i figured it out, that its because it requires to refresh the cache. which is not mentioned in this code. it really dont serve my purpose. another thing which i needed is that,that user can change CSS at runtime through httphandler. i want that user of the site can change the css via httphandler at runtime. can someone help me out in this?
12 David |
Saturday, August 26, 2006 @ 12:37 AM
How come after you set the SuppressContent variable to true, you don't immediately end the request?
if (modifiedSince != null)
{
DateTime dtLastModified = Convert.ToDateTime (fi.LastWriteTimeUtc.ToString ());
DateTime dtModifiedSince = Convert.ToDateTime (modifiedSince);
if (dtLastModified == dtModifiedSince)
{
// The file has not changed
ctx.Response.StatusCode = 304;
ctx.Response.SuppressContent = true;
}
}
sr = fi.OpenText ();
css = sr.ReadToEnd ();
sr.Close ();
13 Milan Negovan |
Monday, August 28, 2006 @ 7:20 AM
There are a couple of ways to end a request. I believe the safest way is to call HttpApplication.CompleteRequest (). I simply didn't see need to interfere with the page life cycle.
14 Priya |
Tuesday, August 29, 2006 @ 11:58 AM
I set the context.user to my custom user class in the Global_AcquireRequestState event. This seems to interfere with the ProcessRequest in the HTTPHandler and the CSS is not generated correctly. Everything works great if I remove the line of code that sets the context.user. Any ideas on how I can overcome this behavior? Any help would be greatly appreciated!
15 Larry |
Tuesday, January 08, 2008 @ 8:46 PM
I always read these types of articles with relish, until I get to the inevitable end - "now we just have to configure IIS" - or something like that. I don't know how many new controls and methods that come with asp.net 2.0 that are completely useless because my site is hosted on a server I have no control over. I've already encountered two or three of them. No hosting company is going to make special allowances for each client.
Sigh...
16 Milan Negovan |
Wednesday, January 09, 2008 @ 7:52 PM
Larry, I feel your pain. When it comes to configuring IIS, you have to jump through hoops to get the hosting company to cooperate.
Ask them. What's described in the article is quite a trivial task and it's their job to help you.
Submit your comment
Please enter only text since all HTML tags except hyperlinks will be stripped.
Hyperlinks will become live links. Any comments with flaming or offensive language will be
deleted. Be courteous to other posters. Thank you.