2005 2006 2007 2008 2009 2010 2011 2015 2016 2017 2018 aspnet azure csharp debugging docker elasticsearch exceptions firefox javascriptajax linux llblgen mongodb powershell projects python security services silverlight training videos wcf wpf xag xhtmlcss

Disabling IIS6 Socket Pooling



Yesterday I ran into one of the worst features of any program ever. In an attempt to setup Subversion on Apache on Windows, I found that Apache couldn't start on the specified IP address using port 80 even though NONE of my IIS6 websites were using this particular IP address. Well, after banging my head against the wall for about an hour, I realized that even though IIS was told to use SPECIFIC addresses for each website, it felt the need to take over ALL the IP addresses on my ENTIRE system!

After a bit of research I found that this "feature" is called Socket Pooling and has been driving people nuts for a while. So, in my attempt to research how to get around this "feature", I found numerous articles online including one on TechNet describing in PARTIAL detail how to fix the problem. Not a single one of the 10+ articles I read explained how to fix this problem correctly.

Here is how you fix this "feature":

Basically you need to tell IIS6 exactly what IP addresses it is allows to use. By default it thinks it has the right to take over ALL your IP Addresses. Not sure why someone thought that was a good idea, but ok...

To tell IIS6 exactly what IP addresses you want to use, thereby freeing up all other IP address, you need the httpcfg.exe utility that comes in the Support Tools on your Windows Server 2003 disc (for R2, it's disc 1) at the follow path:

\SUPPORT\TOOLS\SUPTOOLS.MSI

In my situation, my dedicated hosting service didn't feel that I would EVER need to use ANY of the utilities installed by SUPTOOLS.MSI, so I was stuck there. Furthermore, after wasting about a half hour on searching my closets for a Windows Server 2003 trial disc, I realized that I needed a new plan. If you find yourself in a similiar situation, you can install the Windows XP SP2 Support Tools on your local machine and upload httpcfg.exe to the server. No other files are needed. The Windows XP SP2 Support Tools download is a free file downloadable from the Microsoft website.

After you have httpcfg.exe on the server, get to a command line and get httpcfg.exe in your path (I put the file in the Windows folder).

Now you need to decide what IP addresses you want IIS6 to use. This is where I kept getting confused. Because the default model of IIS6 is to greedily takeover ALL IP addresses, I kept thinking that I wanted to give IIS6 an EXCLUSION. All the articles make it sound like that. All the articles I read made it sound like that was the case. So I kept using httpcfg.exe to include an address in an exclusion list. Well, that's not how it works and the articles should have explicitily stated that. In reality, you tell IIS6 what specific IP addresses you want IIS6 to use and by doing so you are naturally disabling the "feature" of socket pooling. Moving on...

Use the following command to give IIS6 an IP address you would like for it to use (clearly 10.1.1.1 is just an example):

httpcfg set iplisten -i 10.1.1.1

Repeat that for EACH IP address you want IIS6 to use.

If you accidentally set an IP address that you didn't want to add, then you may use the following sample command:

httpcfg delete iplisten -i 10.1.1.1

If you want to see what addresses you have set, use this command:

httpcfg query iplisten

Then STOP the http service by:

net stop http /y

Then START the W3C service by:

net start w3svc

Now your IIS should be running and you should be able to start other web servers as well on different IP addresses. Now, if you find that one of your websites will NOT start and showed up as "stopped" when the other websites started fine, then the IP address for that specific site was not added via httpcfg and you need to do so for that website to start. If that website is using an IP address that Apache or something else is using, you need to choose a different IP address. It's not that big of a deal. That's what DNS was for and if you are using DNS and not just handing out IP addresses, then you won't have a problem.

As a final note, if you are on IIS5 for some reason, then, well, you should upgrade, but say you can't upgrade for some reason, then you too have this same socket pooling "feature", but it's disabled differently. I haven't tried it myself on IIS5, but according to the documenation, you can disable all IIS5 socket pooling by openning a command prompt window and moving to the \Inetpub\AdminScripts folder, then running the following command:

cscript adsutil.vbs set w3svc/disablesocketpooling true

If you see the following response, then you are good. Just stop IIS, then restart IIS and the WWW service to come back online.

disablesocketpooling : (BOOLEAN) True

This method will give you the same nice and happy message on IIS6 as well, but it's just a show intended to give you a false sense of acomplishment and doesn't actually disable socket pooling at all. This method only works for IIS5. You need to use the httpcfg.exe method described above for IIS6.

Firefox 2.0 Bookmark Auto-Backup



The other someone called me up telling me their world has come to and end because they came home to find that someone accidentally deleted all their Firefox bookmarks. The situation was rather serious to them, which is understandable as no one likes to lose anything, so I went over to their place to see what I could do for them. Sure enough the bookmarks were gone, but…

...much to by delight (and their's), I found that Firefox 2.0 keeps automatic backups of your bookmarks for the past 5 days. I found all their bookmarks in the following folder:

%appdata%\Mozilla\Firefox\Profiles\<random stuff>.default\bookmarkbackups

So, I was able to import their bookmarks from a backup and BAM... happiness. That's just a down-right awesome feature that MANY more applications should have. Firefox 3.0 has a new bookmark system called Places which uses SQLite (an open source relation database system) to manage its bookmarks and it should be interesting to see what techniques they use in their final release.

NetFXHarmonics SolutionTemplate/E-Book



Recently I started putting together my standard .NET solution template for public release. This template contains the base architecture and functionality that all my projects need. This template is also organized in a very clear way that clearly separates each type of element into it's own section to maximize expansion and ease of development.

In order to make sure that the solution is understandable by many different types of developers, there are commentaries in each file in the solution. In addition to this, many of the files have full chapter-length lessons on a development topic contained in that file. For example, in the Code/SampleDomManipulator.js file, I wrote a rather extensive introduction to JavaScript browser dynamics through DOM manipulation. Because of these lessons, this solution template is also living .NET e-book.

Here is a list of some of the topics I've written about in this first release of my solution template, some of them are simple explanations and others are lengthy detailed lessons.

  • HttpHandler Creation
  • HttpModule Creation
  • HttpHandlerFactory Creation
  •  
  • Custom Config Section Creation
  • .NET Tracing
  •  
  • MasterPages Concepts
  • Global.asax Usage
  •  
  • CSS Theming, Management, and Media-Specific Sheets
  •  
  • JavaScript Namespaces
  • JavaScript File Consolidation
  • Firefox Console Usage
  • JavaScript Anonymous functions
  • JavaScript Multicast Event Handling
  • DOM Element Creation
  • DOM Element Manipulation
  • DOM Element Deletion
  • JavaScript Event Handling with Low Coupling
  •  
  • JavaScript GET/POST XmlHttp Service Interop
  • Manual XmlHttp Service Creation
  •  
  • JavaScript/CSS/ASP.NET/C# Code Separation
  • Highly Cohesive Type Organization

This solution template could be used for the basis for production projects or as a training utility for people new to ASP.NET, people new to JavaScript, DOM Manipulation or AJAX or people who just want to learn how to organize their projects more effectively.

As with all my projects, but much more so with this one, I will be updating the solution template over time to account for more AJAX techniques and .NET technologies. I will also continue to expand the commentaries and lessons to the point where this solution itself becomes a case study, a sample application, and book all wrapped up in one.

Links

Reflections on Windows Mobile 6 and my T-Mobile Wing



The other day I got my new T-Mobile Wing. This phone is a Windows Mobile 6 device with a pullout keyboard and a whole world of cool features. Last year I had the T-Mobile MDA, which didn't last me a week. This phone fixes a ton of the common problems with Windows Mobile devices, but not only the ones you normally think of. For example, this phone has an almost rubbery texture to it so it doesn't fly across the car and get stuck under my passengers seat every time I dodge someone trying to cut me off. I absolutely love this phone and it was the only phone in the past 4 years that met my EXTREMELY high standards for technology. Before this I was on the Nokia 3650 for many, many, many years and before that I would pre-order and overnight a new $500 cell phone each year directly from Taiwan. So, it takes a lot for me to switch to and keep a phone.

With regard to my service… in my world, a 1500 minute cell plan costs $40.00 with no concept of "US long distance" (i.e. every thing is the US is local) and no concept of roaming (i.e. I can call from anywhere). Period. I have a million features and upgrades on my account, but even with my T-Mobile Hotspot wireless access to every Borders and Starbucks in the world that gives me high speed wireless Internet for BOTH my cell phone AND my laptop, my bill is still under $80 including taxes. Of course I also have the ability to switch phones on a whim by flipping out my SIM card and putting it into my old phone. This comes in very handy. For example, I'm not bringing my new phone to the beach. I'll put my SIM card in one of my Symbian phones for the day. If you want to put up with calling someone to switch YOUR service to another one of YOUR phones, then be my guest. Furthermore, EDGE networking is faster than GPRS and even though it's slower than 3G I'm not an impatient child and I since I get WiFi access at every Borders and Starbucks (and apartment complex via an unsecured Internet router setup by someone who can't read a step-by-step, large-print wireless router setup poster) in the world, I have no problems with speed.

Now… for those of you with Windows Mobile 6 devices, may I recommend that if you want to be as cool as the people with the iPhone, then you should get a few things. First, you seriously need to check out the Picsel web browser. IEMobile is actually an OK browser, Opera also good, and Minimo (Mobile Firefox)… doesn't even pretend to work. Picsel and IEMobile together is the way to go for people like me who loves FREE (as in root beer) much more than FREE (as in speech). Using Picsel you can do some of the the cool stuff the iPhone people are doing like showing the FULL web page in your screen and zooming in and out of it with your finger. I find it absolutely amazing for doing my daily bank account monitoring via my bank's website. It also helps tremendously with my NewEgg.com shopping. iPhone's Safari is a very nice mobile browser, so you don't have all the features… but you have the essentials. Now, for things that have a really nice mobile interface… use IEMobile. There's no point in trying to view the entire Amazon.com in a screen of only 2-3 inches. That's rather intolerable. Viewing a full website newspaper on my phone is NOT something that appeals to me. The point is to get the result you want, not to have a fancy "full" webpage.

Google, Gmail, Google Calendar, Amazon.com, and my ESV Bible have amazing mobile interfaces. Amazon.com one is particularly nice as you can even read book reviews. This came in VERY handy when I was a Borders last night where I wanted to compare local prices with Amazon's and also check out the reviews. So, I whipped out my mobile and looked at the ratings and reviews for each of the books I wanted. Gmail is also incredible as a mobile website. I should note that Windows Mobile 6 supports Gmail as a mail service and that is my primary way of getting mail. I get Gmail notifications on my phone just like any other mail system, but I still like Gmail mobile for browsing the mail already in my box. Google Calendar and my ESV Bible also fit their purposes very well. They are both very minimalistic, but that's how I like it. For websites like these, IEMobile is actually much nicer than Picsel. Needless features and fanciness or ads don't really do it for me on my mobile device.

Also, how about that cool Google maps feature for the iPhone? Guess what… it's a free download from Google for you Windows Mobile device. You can zoom in and out and navigate as needed just as you would do from your desktop web browser. Windows Mobile 6 also comes with Windows Live which also does something similar, though I find their interface less intuitive.

With those two utilities I feel my need to have an iPhone subsided (and guess what… I have MMS and can install my own apps, including ones I've created using the .NET Framework!) However, there are two major things that make an iPhone an iPhone and I'm NOT going to list "it has a real operating system on it" as one. As cool as that is, it's pointless (where's the shell access?) First, the multi-touch surface. That's just insanely awesome. I have so many designs in my head for things I can do with Microsoft Surface it's not even funny anymore. I NEED Microsoft Surface now so I can start building my apps! I can't wait until I and throw away this stupid keyboard and mouse paradigm and start using an interaction system that's actually intuitive (ohhhh how I hate the keyboard-- and ohhh how I wish they would STOP putting a CAPS lock key on there-- it's the most worthless and pointless key ever thought up) Alas, I don't have any multi-touch with my Windows Mobile 6 device. Second, this phone uses a MicroSD card and the largest SD card that's affordable by mere mortals is a 2GB card. What? 2GB? That's NOTHING. The iPhone has 8GB of space and that will probably be doubled very soon. On the bright side though… I can install applications, documents, and data sources (i.e. XML or SQL Server 2005 Compact Edition databases) into my 2GB whereas the iPhone people can only download battery draining music and videos into their 8GB.

As a footnote, let me mention some non-free applications that I'm using. The first is one of the most amazing applications I've ever seen: NewsGator Go. I don't really like their desktop application and as software designer of the Google design school of thought I much prefer the minimalistic Google Reader over the Yahoo-ish NewsGator online. However, their mobile application is just great. To set it up I exported my OPML from my Google Reader and imported it into the online NewsGator and simply logged into my NewsGator Go. It automatically downloaded my settings and updated my RSS feeds. Now THAT'S good software design! I should NEVER be forced to do ANY setup of ANYTHING on my mobile device… Gosh I would LOVE to have a web interface on my desktop to access the Windows Mobile 6 settings.

The other application I use is one that I'm seriously growing addicted to: OneNote 2007 . At this point, I'm talking about the desktop version. It's basically like a personal wiki that just stores all your ANYTHING without you EVER needing to save. AGAIN, this is called good software design (are you taking notes?) Granted, this thing is in absolute desperate need of an online version with magically auto sync and without that feature I'm going to continue to use my own personal wiki to store all my important notes and drafts (BTW, in case you didn't know: MediaWiki is FREE and runs on Linux AND Windows; Apache AND IIS). Still, it does auto sync with OneNote Mobile on my Windows Mobile 6 Device. However (and this is a HUGE however), OneNote Mobile is completely worthless to me because there is absolutely NO option for "send this note". I'm not sure what the people were thinking when they designed that application, but that's fatal design flaw in the same category as Apple's forgetting to add MMS to the iPhone and the IE team forgetting that the W3C runs the web standards, not the IE team.

Lastly, I feel I should at least mention that Money 2006 for Windows Mobile is a free download from Microsoft's website. I'm a local, small town banking person as long as that local, small town bank has a website where I can track my money. I don't really need a WS-Security service to access my information, though that would be nice, but I do need a way to track my daily expenses without using Excel. Money 2006 for Windows Mobile fills this need for my very well.

Minima and Data Feed Framework Renamed and Explained



As of today I'm renaming any of my CTP releases to simply… "releases". That is, my Minima February 2007 CTP is now "Minima - February 2007 Release" and my Data Feed Framework February 2007 CTP is now "Data Feed Framework - February 2007 Release".

The motivation behind these is different for each. With regard to Minima, I knew it wouldn't be a long term or real production project, so announcing it as a CTP was a mistake on my part. Not a big deal. Lesson learned. Furthermore, I knew from the start that it would be more of a training tool than anything else. With regard to my Data Feed Framework (DFF), after using it in various areas I realized that my initial release was sufficient for most scenarios.

As a reminder… what is Minima? Minima is an ASP.NET 2.0 blog engine built using a SQL Server 2005 database and an LLBLGen Pro 2.0 DAL that provides the base functionality that most technical bloggers would need. Since it's initial release I've added some functionality to my own instance of Minima and have used the February 2007 release as a training tool numerous times. Moving forward I want to make it very clear that Minima is primarily a training tool and a such, it's a blog template that people learning ASP.NET can enhance and upgrade to aide in their own personal learning. Having said that, Minima is a full fledged blog engine and it does have features such as labels and the ability to have more than one URL point to the same entry. In any case, if you want something to help you learn the various components of ASP.NET, please feel free to take Minima and use it as you please (see attribution/licensing note below).

By using Minima as a training tool you can learn much about base ASP.NET technology as well as manual Ajax prinicples, CSS theming, HttpWebRequest, proper use of global.asax, framework guidelines, and type organization. Furthermore you can use it to learn WCF, the power of HTTPHandlers, and how to effectively utilize LLBLGen Pro. I will try to release versions of Minima to demonstrate the new technologies of the day. For example, when ASP.NET Ajax matures a bit (I find it slower than a dead turtle right now), I'll be adding portions to demonstrate ASP.NET Ajax. However, I will not be adding new functionality for the sake of functionality. If the functionality can be used as a training tool, then I will add it. Also, Minima is a great way of learning WPF. How so? I deliberately did NOT include a client! Why? Because I would rather you use whatever you want to use to create a simple form to access the API via WCF. The client I use a very basic WPF client that calls the Minima WCF service. So far, Minima has been a very effective learning tool and I hope you will find it useful as well.

As far as my Data Feed Framework (DFF). What is it? It's a self-contained framework that converts SQL statements into RSS feeds. I've used this in a number of places where creating a manual RSS feed and MANAGING the RSS feeds would just be too time consuming. For example, say you have a ASP.NET 2.0 e-commerce website and you have new products released at various intervals. Well, it would be AWESOME if you had an RSS feed to announce new products and sales without having to send out an ethically questionable e-mail blast. With DFF, you simply write something like "select Title=ProductName, Description=ProductDescription from Product where ProductDate > '7/11/07' order by ProductDate desc" and BAM you have an RSS feed. Since an RSS feed is simply a select statement in a column in a row in a SQL Server table, you could also use it to dynamically create a custom feed for each person who wants to monitor the price of a certain product. It's very flexible. RSS feeds are accessible via their name, their ID, or you can use a "secret feed" to force a feed to be accessible via GUID only. DFF also includes some templating abilities to help customize the output of the RSS feed. In addition to the DFF SQL to RSS engine, DFF also includes an ASP.NET 2.0 control called an InfoBlock that allows you to consume any RSS feed and display it as an XHTML list. You can see an example of how to use an InfoBlock my looking at my blog. The boxes on the right are InfoBlocks which allow me to manage my lists using a SQL Server table (the DFF database contains a Snippet and a SnippetGroup table to store autonomous information like the information in these lists--please see the documentation for more information). DFF is creating secret RSS feeds that my own personal version of Minima then consumes. With this as an example, it should be easy to see how DFF can be used in portals. My DFF demonstration video shows a bit more of that.

For more information regarding my Data Feed Framework (DFF), please skim the concise documentation for Data Feed Framework linked below. It would also probably be a good idea for you to watch my short video documentation for DFF as well. Please note that even though DFF is designed to be a production framework, it too can be used as a training tool. The most obvious thing you can learn is how to create data-bound server controls for ASP.NET 2.0 as this is exactly what an InfoBlock is.

You may use either the SQL->RSS engine or the InfoBlock portion or both. It's up to you. Also, as with all my .NET technologies that I create, the source and database files are included for extensibility and so you may use these as training tools (for yourself or for others). Lastly, for both Minima and Data Feed Framework, please remember to keep the license information intact and make it very clear that your work either uses or is based on either whichever product you are using.

Minima - Links

Data Feed Framework - Links

Moonlight: Mono's Silverlight



Here's something rather interesting… the developers on the Mono team "hacked" Silverlight and it only took them 21 days to do it. They are calling their own product "Moonlight", which I have to admit is a much cooler product name than Silverlight.

Project details as well as some internal information including a bit of information about Silverlight internals are are the link below. Even if you care nothing about Mono or Moonlight, if you have any interest in Silverlight at all you should check it out simply for that.

This is actually really cool as it should seriously help promote Silverlight as a de facto standard worldwide, but I doubt anyone will be making a documentary called "21 Days" any time soon.

Silverlight's Adoption as Public De-Facto Standard



Recently there have been comments floating around the internet and around conferences that Microsoft's Silverlight needlessly uses XAML as its mark up language where it should have used SVG (Scalable Vector Graphics). The argument here is based on the idea that since SVG is a vector technology accepted in all web browsers except IE, Microsoft should have used it instead of XAML and then simply added support for SVG to IE. While this seams to some to be a valid criticism and a good point to some of the web standards world, it is absolutely groundless and carries no weight.

Silverlight can be viewed as a web extension of the Windows Presentation Foundation (WPF), a .NET 3.0 technology and not simply as a new web technology. As such, it makes sense that Silverlight uses XAML, not SVG. If Silverlight were based on SVG, then there would be a chasm between Silverlight and the .NET Framework, but as it stands Silverlight's use of XAML makes it part of the .NET family. In fact, it’s important to note that elements in XAML usually represent objects in the .NET Framework; this would simply not be possible in SVG. Therefore, by choosing to use XAML over SVG, Microsoft kept SVG pure by not add proprietary technology to it.

Furthermore, SVG is "Scalable Vector Graphics" and as the name suggests it for vector graphics. If Microsoft were to start out with SVG as their base technology they would quick to add UI controls to it thereby altering it making it a Microsoft dialect of SVG, which would not be SVG at all. This would take the entire web world back to the same disasters that were seen in proprietary HTML elements, proprietary CSS selectors and rules, and proprietary JavaScript dynamics (i.e. "DHTML behaviors"). Aside from the architects and developers on the Internet Explorer team, the world, including Microsoft as a whole, thankfully has a lot more respect for specifications and standards than this.

Standards advocates should be very satisfied with Microsoft's decision to start from scratch on this one. Standards, as they are normally referred to as, deal with standardization and thereby allow everyone to talk about the same technology without proprietary terminology or technology. If Microsoft sets an explicit syntax on a well-defined language, publicly states the specification for the language, and makes it a multi-platform language, then the world has basically the same result that a standard would have (this point will be hit again in a moment.) While it's true that "popular" doesn't make things right (something most people learn early in high school) and that statements about "most people" do not mean a single thing, having a well-defined technology set with a set specification does make it a first class technology.

We can see this in the ECMA-334 (C#) specification. Microsoft could have taken JavaScript and forced it to obey the Common Language Specification (CLS) and pawned it off as the primary .NET Language, but they instead chose to create something entirely new and then publicly displayed the specification for it. So when .NET guides are written the samples usually have code for C# and VB, instead of JScript and VB. Those who criticize Microsoft for not using SVG as their client-side technology probably applaud Microsoft for creating a new programming language.

Lastly, it should be noted that one of the primary purposes of using the web as a platform is to make something more accessible. People should be able to use any sufficiently advanced web browser to access a web page or web application anywhere on the entire Internet. Truly, even if an application is created in a corporate environment, if the technologies used are proprietary to any one specific web browser, the primary purpose of using a web browser is defeated and using a smart client would probably give a much richer experience and result. So, while it is true then that the use of proprietary technology, such IE specific content, defeats the entire purpose of using the web as a platform, if a technology is spread enough, is on enough platforms, and allows integration into their current environment (i.e. Firefox, Safari, Opera), it doesn't need to be a standard because it would achieve the same result as a standard. Flash is probably the best example of this.

In conclusion, there should not be much fuss about Microsoft's new "Flash-killer" using what some would view as private corporate technology. As long as there is support for Silverlight in Firefox, Opera, Safari on Windows, Mac OS X, and Linux and a seamless installer experience, there shouldn't be any problem with a rapid world wide adoption of this new technology. Hopefully Silverlight's adoption into the web as a de-facto standard will silence many forms of critisism about it and help prompt developers to do a better job of creating intranet and Internet solutions for muliple platforms and multiple web browsers.

The ECMA-334 Standard



Let me state publicly for the record: I do not approve of books for learning C#. The only guide you will ever need is the ECMA-334 standard. It's a readable guide to the entire C# language that covers every facet of the language. This document is the definitive guide for C#. In fact, there is no document on MSDN that even comes close to the comprehensive native of C# than does the ECMA-334 standard as the ECMA-334 standard is C#.

Why do I mention this at all? Because, from time to time I get people asking me what book he or she should *buy* to learn C# and I always tell them what I've just stated above. Unlike Visual Basic, C# is NOT Microsoft's baby. They may have been the ones who gave birth to C# and continue feed it and nurture it, but it's a standard -- not Microsoft's baby.

Lastly, while you are getting the ECMA-334 standard, check out the ECMA-335 standard. This one is the standard for the CLI (Common Language Infrastructure -- which Microsoft implements as the CLR or Common Language Runtime). It goes into detail about the IL (Intermediate Language), the Common Language Specification (CLS), the Common Type System, and talks in some detail about various .NET concepts. I would consider this standard to be more advanced than what most people need at first, so I don't recommend this for initial learning (for that get Duffy's Professional .NET Framework 2.0 [0764571354] and then Richter's CLR via C# [0735621632]).

As a footnote, you could also check out the ECMA-262 standard (ECMAScript, that is, JavaScript), but it's not nearly as well written as the ECMA-334 and ECMA-335 standards and because of that I've never recommended it's reading to anyone.

CSS Architecture Overview



As a technology architect who has an emphasis in web architecture, one thing that I find that most ASP.NET completely misunderstand is the concept of CSS architecture.  It's incredibly important to learn that CSS is not simply "styling". This is one of the most common misconceptions about CSS in existence. CSS is more than the silly “style” attribute on XHTML elements. If that were the case, then none of us should ever rely on CSS as the “style” attribute does little more than dramatically increase the coupling between page structure and style.

Fortunately , however, CSS is more than simply "styling". In fact, CSS is an acronym that stands for Cascading Style Sheets. It's not just some nice marketing acronym used to make the technology sound cool, but is rather a very well thought out acronym that explains CSS very well. When most people come to CSS, they only look at the middle letter ("style") and completely ignore the other two letters completely. You need to understand each of the letters in order to fully grasp the architectural power of CSS.

The third letter represents CSS is "sheet". This means that CSS is a technology designed to be placed by itself in its own file.  By keeping your CSS rules away from your XHTML structure you are maximizing the potential of your system be removing all coupling and maximizing cohesiveness. That is, your XHTML is doing what it does best by representing the page structure, leaving CSS to do its job by focusing on the visual elements. There is no sharing of responsibilities and the aren't directly tied to each other, thereby allowing reuse of your CSS rules.

There are secondary reasons for doing this as well. One of them deals with manageability.  Instead of being forced to change each "style" attribute on each element across multiple files manually, you now have a centralized place for your style.  Saying "it's just one 'style' attribute, what's it going to hurt?" is a sign of laziness and unprofessionalism that will leads only to more people saying the same thing leading to a complete nightmare of spaghetti code. Imagine if people did that with C# and ASP.NET: "what's the big deal? It's only one script block." You can destroy anything by taking cutting corners.

Another secondary advantage of keeping your CSS in "Style Sheets" (CSS sheet) is that it keeps your client download time to a minimum. If you keep your CSS away from your ASP.NET/XHTML structure, your client web browsers can cache the XHTML document and CSS page separately.  When the ASP.NET/XHTML page changes, the web browser doesn't need to get all the CSS information again. In the same way, if you need to change the "style" of something, you can do so in the CSS sheet without affecting anything else. If you kept your CSS either in the "style" attribute as a sloppy blob of CSS rules in a <style/> element, then even the slightest color change is a modification of the ASP.NET/XHTML structure leading to a recompilation.  You may have killed your page cache as well.

The cascading nature of CSS, or to the “C” in CSS, is also at the heart of CSS architecture. If you manage your CSS sheets correctly, then you should have a system where you can literally change one file and have it reflect across potentially thousands of pages. Your changes will naturally flow from XHTML page to XHTML page, from CSS to CSS, and from parent elements to child elements with well thought out, virtually object-oriented element style overriding. Trying that with HTML or with CSS coupled to your XHTML elements or pages!

By working with CSS as true CSS, not simply as a nice technology to change font sizes and colors, we are able to take the potential of CSS to its logical conclusion: CSS themes. If you create a set of CSS sheets that specify the images, layout, colors, and various other style related aspects a specific look and feel, then you are in the perfect place to allow themeing of your web site.  If the term "theme" doesn't appeal to you, what about the term "branding"?  A few years ago I was involved in a project for a major fast food chain who had about 10 different brands.  They basically wanted 10 different store fronts, which made the resident e-commerce developer about flip out.  However, using a properly designed CSS architecture, I was able to provide a simple, yet powerful branding model.  First, I defined the XHTML structure based on their semantic representation.  Second, I applied a colorless and image-less CSS page which gave each website its element positioning.  Third, I gave each brand its own folder with its own root CSS page and its own images and other media files.  All the developer had to do was look at the URL path to obtain the brand name and then change a single CSS page between brand.  The developer was actually able to sleep that night.

As you can see from this story, CSS themes can be very powerful and save a lot of time.  You could event go more complex in your CSS themes.  For example, you could use a CSS coordinator.  Then is when you attach a single CSS sheet to your XHTML page and have that single CSS sheet contain a series of “@import” statements.  You could then actually change the look and feel of your entire website without ever touching the ASP.NET/XHTML structure and thereby never forcing a recompile anywhere.  I often use this technique to coordinate a CSS page for screen size (800.css, 1024.css, 1280.css) with a theme (plain.css, green.css, blue.css), with a core feature set (report.css, membership.css, landing.css-- which would be tiny, so your landing page is very quick to load).  This technique should look familiar to anyone deep into object-oriented design as it's similar to some of the GoF structural design patterns. Having said that, this is not always a required technique and sometimes it can lead to caching problems itself. For example, how will the page know to get the new CSS sheet? Sometimes it's OK to invalidate cache or to force a recompile.

Another reason for proper CSS design that is continually growing in importance is media specific CSS. Say you created a screen for management that allows simple report creation. You put a set of ASP.NET controls next to the report to allow management to refine the report data. How can you allow management to print the report without printing the ASP.NET controls? How can you turn off the colors of the report to maximize print quality on a black laser printer? How can you remove the application header from the form so that the report prints professionally or to make sure the document prints on one sheet? All these things are possible with media specific CSS. By having one structure stating the content of the document you have a base level entity that can then be transformed to various output media. Media specific CSS works for more than just printers. If you thought ahead in your web architecture and therefore created a proper semantic representation of your XHTML elements and separated your CSS from your XHTML, you can easily add light-weight mobile support with very little effort. When a web browser views your page it will display in all its glory, when a printer accesses the page the buttons and header will be gone, and when a mobile device views the page the sidebar is now hidden, the fonts are now smaller, text shows in place of images, and the menu is now abridged.

You can easily add media specific CSS to your documents by placing more <link /> elements in your XHTML head element.

For example, the following will set a general CSS page, a print theme, and a mobile theme.

<link href="Style/ClassicTheme/default.css" rel="stylesheet" type="text/css" />
<link href="Style/ProfessionalPrintTheme/default.css" media="print" rel="stylesheet" type="text/css" />
<link href="Style/SimpleMobileTheme/default.css" media="handheld" rel="stylesheet" type="text/css" />

One thing you may want to keep in mind about this is that the iPhone is not considered a “handheld” device. To add a media specific CSS page to the iPhone, please see this article.

It's hard to overestimate the importance of proper CSS architecture, yet I find that most web developers have never even heard of this before.  I suspect that it's because its a fusion of diverse topics which with most web developers aren't familiar.  For example, many ASP.NET developers I work with know software architectural principles, but can't even spell CSS.  Other times, I'll see awesome web designers who have no idea what software architecture is.

XmlHttp Service Interop - Part 3 (XML Serialization)



In this third part of the series, I discuss how to manually create an XML service and a SOAP service using XML serialization to maximize the flexibility in your service interop work. The technique allows you to very quickly accept just about any XML format from the wire and work with it in a strongly typed manner in your .NET applications.