<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>C# / ASP.net</title>
        <link>http://blog.caffeinatedsoftware.com/category/16.aspx</link>
        <description>All things web server related</description>
        <language>en-US</language>
        <copyright>&lt;i&gt;&lt;b&gt;Caffeinated&lt;/b&gt;&lt;/i&gt; Software</copyright>
        <generator>Subtext Version 2.1.0.5</generator>
        <item>
            <title>Is Flanagan’s “Rhino book”, the Petzold of the web era?</title>
            <link>http://blog.caffeinatedsoftware.com/archive/2008/03/08/is-flanagans-rhino-book-the-petzold-of-the-web-era.aspx</link>
            <description>&lt;p&gt;&lt;img align="right" alt="" src="http://blog.caffeinatedsoftware.com/images/blog_caffeinatedsoftware_com/030908_0753_IsFlanagans1.png" /&gt;10 or so years ago, when one wanted to write a Windows application, you had a choice to make. Does one take the easy way, or the hard way?  Were you a real Windows Software Engineer or a wanna be? Did you use Visual Basic, or did you take the time master all the nuances of &lt;a href="http://msdn2.microsoft.com/en-us/library/ms632597(VS.85).aspx"&gt;HWNDs&lt;/a&gt;, &lt;a href="http://msdn2.microsoft.com/en-us/library/ms533241.aspx"&gt;HDCs&lt;/a&gt;, and &lt;a href="http://msdn2.microsoft.com/en-us/library/ms644950.aspx"&gt;SendMessage&lt;/a&gt;? Was  &lt;a href="http://www.charlespetzold.com/"&gt;Charles Petzold's&lt;/a&gt; seminal &lt;a href="http://books.google.com/url?client=ca-google-gppd&amp;amp;format=googleprint&amp;amp;num=0&amp;amp;channel=BTB-ca-google-gppd+BTB-ISBN:157231995X&amp;amp;q=http://www.amazon.com/exec/obidos/ASIN/157231995X&amp;amp;usg=AFQjCNEmAnUTjM4NIL-hpzzqmDmjQUxeFg&amp;amp;source=gbs_buy_r"&gt;Programming Windows&lt;/a&gt; book on your bookshelf or not? Did you enjoy the &lt;a href="http://www.youtube.com/watch?v=zSgIb0xBQhk"&gt;Get a Mac - Gift Exchange ad&lt;/a&gt; in which PC gives Mac a copy of the "C++ GUI Programming Guide"? &lt;/p&gt;
&lt;p&gt;Today, it seems the web programming world has a evolved into a similar dicotemy. It seems there are lot of ASP.net programmers who are more like the VB programmers of yore, than the C/C++ programmers of eras past. &lt;/p&gt;
&lt;p&gt;There are those who avoid getting their hands dirty with Javascript and really don't understand the full power of the browser's DOM. You know the ones that don't even know &lt;a href="http://blog.caffeinatedsoftware.com/archive/2008/01/11/best-asp.net-interview-question-ever-part-1.aspx"&gt;what byte bloat ASP.net web forms can create&lt;/a&gt;, let alone how or why they should avoid it.  &lt;/p&gt;
&lt;p&gt;Granted, like old Visual Basic, ASP.net web forms is a great tool for writing applications quickly. But the native tongue of Windows is the &lt;a href="http://msdn2.microsoft.com/en-us/library/aa383749(VS.85).aspx"&gt;C/C++ Win32 API&lt;/a&gt;, and the best application developers are fluent in it. Likewise, the native tongue of the Web is the &lt;a href="http://www.w3.org/DOM/"&gt;Javascript HTML DOM API&lt;/a&gt;, and the best application developers exploit every byte of power the web platform can offer application developers and &lt;a href="http://www.joelonsoftware.com/articles/LeakyAbstractions.html"&gt;avoid platform abstractions&lt;/a&gt;. Like the Windows developers of yore, the best ASP.net applications are written a little closer to the metal than most people are able or willing to go.  &lt;/p&gt;
&lt;p&gt;I don't know if I really have a point, other than sometimes large frameworks filled with time saving abstractions get in your way, more than they help. Sometimes, you need to get under the hood and get your hands dirty. Sometimes, I wish more developers had the opprotunity to build fast applications, instead of merely developing applications fast.&lt;/p&gt;&lt;img src="http://blog.caffeinatedsoftware.com/aggbug/36.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>&lt;i&gt;&lt;b&gt;Caffeinated&lt;/b&gt;&lt;/i&gt; Software</dc:creator>
            <guid>http://blog.caffeinatedsoftware.com/archive/2008/03/08/is-flanagans-rhino-book-the-petzold-of-the-web-era.aspx</guid>
            <pubDate>Sun, 09 Mar 2008 07:53:14 GMT</pubDate>
            <wfw:comment>http://blog.caffeinatedsoftware.com/comments/36.aspx</wfw:comment>
            <comments>http://blog.caffeinatedsoftware.com/archive/2008/03/08/is-flanagans-rhino-book-the-petzold-of-the-web-era.aspx#feedback</comments>
            <slash:comments>6</slash:comments>
            <wfw:commentRss>http://blog.caffeinatedsoftware.com/comments/commentRss/36.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Return of a Jedi  </title>
            <link>http://blog.caffeinatedsoftware.com/archive/2008/02/13/return-of-a-jedi.aspx</link>
            <description>&lt;p&gt;&lt;img alt="" align="left" src="http://blog.caffeinatedsoftware.com/images/blog_caffeinatedsoftware_com/021308_2055_ReturnofaJe1.png" /&gt; It was a long, long time ago… It was a time of a great civil war between the Outlook/Office and the Exchange teams… It was a time of great browser wars and much uncertainty... It was an era in which ancient languages such as C++ ruled the galaxy and web browsers weren't considered application development platforms. &lt;/p&gt;
&lt;p&gt;It was during this time, I had the opportunity to work on a product that would help redefine web based e-mail and more importantly define what web applications were capable of. I was one of the first developers on the Outlook Web Access team (or as it was known back then, the Exchange Web Client). During 1996-1998, I worked with Bob Gering (R.I.P.) and &lt;a href="http://msexchangeteam.com/archive/2005/06/21/406646.aspx"&gt;Jim Van Eaton&lt;/a&gt;, where I created the original appointment / meeting request form, the contact form, and the Java date picker. Needless to say, it was the highlight of my professional career at Microsoft. &lt;/p&gt;
&lt;p&gt;Unfortunately, during this great civil war, my career ended up following a different path, than that of my good friends, and I joined "the confederacy". During this period, I ended up working on random Office apps in native code, as I meandered around aimlessly from group to group, either working on products I wasn't passionate about or working for managers who were mediocre. After a few years of my career going nowhere, I left Microsoft. &lt;/p&gt;
&lt;p style="TEXT-ALIGN: justify"&gt;During this time, my friend Qui-Gon Jim (Van Eaton) became the Jedi Master of the &lt;a href="http://www.microsoft.com/exchange/code/OWA/index.html"&gt;Outlook Web Access&lt;/a&gt; team, and under his stewardship &lt;a href="http://www.alexhopmann.com/story-of-xmlhttp/"&gt;OWA became the first web application to use the XMLHTTP technology&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/AJAX"&gt;which is today referred to as AJAX&lt;/a&gt; and continued to grow its proud legacy into the great application you know and love today. Unless of course, you use a browser &lt;a href="http://www.getfirefox.com"&gt;that doesn't suck&lt;/a&gt;, in which case you'll never know how good OWA really is, which brings us to the present day. &lt;/p&gt;
&lt;p&gt;You see, Microsoft fumbled the ball during the dot com bust. After building a huge market share &amp;amp; mind share lead in the browser wars, Microsoft disbanded the IE team and essentially walked away from improving its client side internet technologies (fortunately, they invented .net during this time, and improved it's server side software, but IE was essentially trapped in a time capsule from 2001-2005). I suppose at the time it seemed like a smart move since AOL purchased Netscape, and neither AOL, Netscape nor the Mozilla foundation were going anywhere. Furthermore, Steve Jobs second coming at Apple was still in its early stages and Google was merely a good search engine and not yet a verb. &lt;/p&gt;
&lt;p&gt;Except, at some point during that era, we hit a strategic inflection point. Firefox got invented, kept improving and kept innovating. All while the majority of the former IE team was trapped in &lt;a href="http://www.amazon.com/Mythical-Man-Month-Software-Engineering-Anniversary/dp/0201835959"&gt;the Vista tar pit&lt;/a&gt;. In a few short years, IE 6 went from first to worst in mind share, due to the Firefox team playing the tortoise to Microsoft's hare. Even worse, Google took advantage of Microsoft's internet client myopia and made a web e-mail client that worked great on IE and Firefox (and gave away gigabytes of storage space to sweeten the deal). Shortly afterward Apple released Safari, Google released Google Maps, Microsoft released Virtual earth, and the Web was re-born. &lt;/p&gt;
&lt;p&gt;Anyway, the OWA team kept innovating during this era of uncertainty, and ended up with a great AJAX client that only worked on IE because when it was designed 1) there were no other browsers that supported AJAX / DHTML except IE and 2) there were no standards to follow because there were no other browsers that had implemented them yet. I suppose myopia played a role as well, but by the time the other browsers gained mind share, the OWA's development plans were already set in &lt;a href="http://starwars.wikia.com/wiki/Carbon_freezing"&gt;Carbonite&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;When I was on the OWA team, we supported IE &amp;amp; Netscape equally well (perhaps equally poorly is a better choice of words, because web browsers and web applications were so much simpler &amp;amp; less complex back then). However, during the past 10 years, we've witnessed the rise and fall of Internet Explorer (and &lt;a href="http://blogs.msdn.com/ie/archive/2007/12/19/internet-explorer-8-and-acid2-a-milestone.aspx"&gt;possible redemption&lt;/a&gt;) and the World Wide Web is once again a chaotic and exciting area of uncertainty and innovation. &lt;/p&gt;
&lt;p&gt;So, with that back story, I am now announcing that this epic tale, is taking a new, if small, unexpected twist. Qui-Gon Jim has asked this former Jedi Knight to return to the &lt;a href="http://www.nytimes.com/2005/08/24/technology/24valley.html"&gt;Rebel Alliance&lt;/a&gt;, where we both hope we can defeat &lt;a href="http://thesithari.blogspot.com/"&gt;Darth Page and Darth Brin&lt;/a&gt; of the &lt;a href="http://www.oreillynet.com/windows/blog/2005/08/is_google_evil.html"&gt;Google Empire&lt;/a&gt;. For the past few years, I've been peacefully living on &lt;a href="http://en.wikipedia.org/wiki/Tatooine"&gt;Tatooine&lt;/a&gt;, but Qui-Gon Jim's call to battle was too compelling to resist. &lt;/p&gt;
&lt;p&gt;With a lot of hard work, and a little luck, perhaps I shall become a Jedi Master and re-join the Jedi Council. If nothing else, perhaps I'll merely play Han Solo for a few months and pay off Jabba the Hutt. &lt;/p&gt;
&lt;p&gt;&lt;img alt="" align="right" src="http://blog.caffeinatedsoftware.com/images/blog_caffeinatedsoftware_com/021308_2055_ReturnofaJe2.png" /&gt;One thing is for certain, the light saber fights with the Sith are going to be fun to watch and I'm looking forward to seeing something other than IE 6 bugs for next several months. Wish me luck in my &lt;a href="http://blogs.msdn.com/oldnewthing/"&gt;old / new job&lt;/a&gt; on Microsoft's Outlook Web Access team!&lt;/p&gt;&lt;img src="http://blog.caffeinatedsoftware.com/aggbug/33.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>&lt;i&gt;&lt;b&gt;Caffeinated&lt;/b&gt;&lt;/i&gt; Software</dc:creator>
            <guid>http://blog.caffeinatedsoftware.com/archive/2008/02/13/return-of-a-jedi.aspx</guid>
            <pubDate>Wed, 13 Feb 2008 20:55:51 GMT</pubDate>
            <wfw:comment>http://blog.caffeinatedsoftware.com/comments/33.aspx</wfw:comment>
            <comments>http://blog.caffeinatedsoftware.com/archive/2008/02/13/return-of-a-jedi.aspx#feedback</comments>
            <slash:comments>6</slash:comments>
            <wfw:commentRss>http://blog.caffeinatedsoftware.com/comments/commentRss/33.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Best ASP.net Interview Question Ever (Part 2)</title>
            <link>http://blog.caffeinatedsoftware.com/archive/2008/01/12/best-asp.net-interview-question-ever-part-2.aspx</link>
            <description>&lt;p&gt;&lt;img align="left" alt="Comic Book Guy thinks &amp;quot;IE 6 - worst browser ever&amp;quot;" src="http://blog.caffeinatedsoftware.com/images/blog_caffeinatedsoftware_com/011208_1759_BestASPnetI1.gif" title="Comic Book Guy thinks &amp;quot;IE 6 - worst browser ever&amp;quot;" /&gt;&lt;a href="http://blog.caffeinatedsoftware.com/archive/2008/01/11/best-asp.net-interview-question-ever-part-1.aspx"&gt;Last time&lt;/a&gt;, I whined about ASP.net byte bloat. As long as I'm bitching about Microsoft's internet platform, I might as well hold nothing back. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Microsoft doesn't care enough about Internet Explorer.&lt;/strong&gt; It is the red headed step child of Microsoft's internet platform. MS seriously lost a lot of client side credibility and goodwill by disbanding the Windows IE team for 3+ years after Windows XP / IE 6 shipped and letting the &lt;a href="http://www.mozilla.com/en-US/about/"&gt;Mozilla / Firefox team&lt;/a&gt; catch up and surpass it.&lt;br /&gt;
&lt;br /&gt;
I'm sure &lt;a href="http://www.theregister.co.uk/2005/12/19/ms_kills_ie_mac/"&gt;killing Mac IE&lt;/a&gt; &amp;amp; &lt;a href="http://www.extremetech.com/article2/0,1697,587342,00.asp"&gt;killing Unix IE&lt;/a&gt; didn't help matters either (not that anybody ever used them). Shipping a mediocre IE 7 along with a &lt;a href="http://blog.caffeinatedsoftware.com/archive/2007/04/15/My-Vista-Test-Drive.aspx"&gt;disappointing Vista&lt;/a&gt; last year, has further hindered Microsoft's ability to convince people that it does have a great server side web platform and annoyed its supporters. I'm also annoyed that after IE 7 shipped, the &lt;a href="http://blogs.msdn.com/ie/"&gt;IE blog&lt;/a&gt; has been less informative during the IE 8 dev cycle than it was during IE 7's. I'm optimistic that after the recent &lt;a href="http://blogs.msdn.com/ie/archive/2007/12/19/internet-explorer-8-and-acid2-a-milestone.aspx"&gt;IE 8 Acid Test&lt;/a&gt; post, the group is just being quiet instead of dead. &lt;/p&gt;
&lt;p&gt;However, barring a &lt;a href="http://seattletimes.nwsource.com/html/jerrybrewer/2004109750_brewer06.html"&gt;Seahawk like comeback&lt;/a&gt; by the IE 8 team, my money is on &lt;a href="http://mozillalinks.org/wp/category/subject/firefox3/"&gt;Firefox 3&lt;/a&gt; being the champ in the 2008 browser bowl. Ever since &lt;a href="http://blogs.msdn.com/dmassy/"&gt;Coach Dave Massy left the IE team&lt;/a&gt;, I think they've taken a step backwards. Maybe they need to give IE to Coach &lt;a href="http://weblogs.asp.net/scottgu/"&gt;Scott Guthrie&lt;/a&gt; (GM for all things &lt;a href="http://www.iis.net"&gt;IIS&lt;/a&gt;, &lt;a href="http://asp.net/"&gt;ASP.net&lt;/a&gt;, &lt;a href="http://silverlight.net/"&gt;Silverlight&lt;/a&gt;, and all other MS web technologies that don't suck) or perhaps the GM Windows Live team (Did you know &lt;a href="http://weblogs.mozillazine.org/mitchell/archives/2007/01/the_mozilla_foundation_achievi.html"&gt;Firefox development is almost completely funded by Google ad revenue&lt;/a&gt;?) All I know is that IE is too important to be left in the Windows group. Microsoft needs to show more forward progress and give the season ticket holders reason to be hopeful. Otherwise, IE will be like Shaun Alexander, a browser/back that has a great history and a disappointing present.&lt;br /&gt;
&lt;br /&gt;
OK, I got the big 2 gripes off my chest. Here are some minor ones. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Why does ASP.net AJAX download so many Javascript files? &lt;/strong&gt;I think there's a new &lt;a href="http://msmvps.com/blogs/luisabreu/archive/2007/06/12/toolkitscriptmanager-there-s-a-new-scriptmanager-in-town.aspx"&gt;ScriptManager on CodePlex&lt;/a&gt; that combines several embedded scripts on a single download. Still, it would've been nice if it was this way by default.&lt;strong&gt;&lt;br /&gt;
&lt;br /&gt;
Why is HTTP compression the best kept secret of IIS? &lt;/strong&gt;Seriously, it seems the vast majority ASP.net programmers don't know about HTTP compression on IIS. Maybe all of my friends read &lt;a href="http://dilbert.com/"&gt;Dilbert&lt;/a&gt; instead of &lt;a href="http://www.codinghorror.com/blog/archives/000059.html"&gt;Jeff Atwood&lt;/a&gt; during their lunch break? OK, it is a &lt;a href="http://www.dotnetjunkies.com/HowTo/16267D49-4C6E-4063-AB12-853761D31E66.dcik"&gt;pain to configure&lt;/a&gt; and providing some UI, like what &lt;a href="http://www.port80software.com/products/zipenable/"&gt;Port 80 Software's ZipEnable&lt;/a&gt; does, would be welcome. People get nervous when I say edit the IIS metabase around them.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Why did I have to wait so long for a real FTP server? &lt;/strong&gt;Oh well, at least &lt;a href="http://www.iis.net/articles/view.aspx/IIS7/Managing-IIS7/Using-FTP-Server-in-IIS7/What-s-New-for-Microsoft-and-FTP-"&gt;things are better in IIS 7&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
As I said, in my first post, on the whole, I'm pretty happy with Microsoft's internet platform. The ASP.net team is adding cool features at a good clip, Silverlight seems like a promising addition to the web developer's tool chest, and IIS 6 has been simple to use &amp;amp; rock solid in deployment. It seems like half of the ASP.net engineering team blogs, so getting that level of transparency is awesome. Visual Studio 2008 &amp;amp; SQL Server 2008 both seem like worthwhile upgrades.  &lt;/p&gt;
&lt;p&gt;And yet, despite all this coolness, I still have to code work-a-rounds for IE 6 bugs in my day to day life! To be fair to Microsoft, IE 6 &lt;em&gt;was&lt;/em&gt; a great browser in 2001. Unfortunately, it's 2008 now and Microsoft fumbled away the web browsing technology dominance it once had. We're all stuck writing apps for a 7 year old web browser, that doesn't compare well to today's best players. Oh well, here's hoping that both IE &amp;amp; 37 will return to All-Pro form next season.&lt;/p&gt;&lt;img src="http://blog.caffeinatedsoftware.com/aggbug/32.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>&lt;i&gt;&lt;b&gt;Caffeinated&lt;/b&gt;&lt;/i&gt; Software</dc:creator>
            <guid>http://blog.caffeinatedsoftware.com/archive/2008/01/12/best-asp.net-interview-question-ever-part-2.aspx</guid>
            <pubDate>Sat, 12 Jan 2008 17:59:39 GMT</pubDate>
            <wfw:comment>http://blog.caffeinatedsoftware.com/comments/32.aspx</wfw:comment>
            <comments>http://blog.caffeinatedsoftware.com/archive/2008/01/12/best-asp.net-interview-question-ever-part-2.aspx#feedback</comments>
            <slash:comments>3</slash:comments>
            <wfw:commentRss>http://blog.caffeinatedsoftware.com/comments/commentRss/32.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Best ASP.net Interview Question Ever (Part 1) </title>
            <link>http://blog.caffeinatedsoftware.com/archive/2008/01/11/best-asp.net-interview-question-ever-part-1.aspx</link>
            <description>&lt;p&gt;&lt;img border="0" align="right" alt="Comic Book Guy ponders ASP.net" src="http://blog.caffeinatedsoftware.com/images/blog_caffeinatedsoftware_com/011208_0756_BestASPnetI1.gif" title="Comic Book Guy ponders ASP.net" /&gt;I recently I had a job interview w/ &lt;a href="http://www.costco.com"&gt;Costco Wholesale&lt;/a&gt; in the e-Commerce group. I thought the most interesting question they asked was "If you could change one thing about ASP.net, what would it be". It was a hard question, because on the whole, I'm pretty happy with it. Furthermore, on the whole, I'm pretty happy with the direction that Microsoft is going. However, it got me thinking about what I don't like about Microsoft's internet platform and I figured it would make a great blog post (or two), so here I go. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Viewstate + ClientID = HTML Bloat + Slow.&lt;/strong&gt; I don't think the ASP.net forms model is bad; it just makes it much more difficult than necessary to produce small HTML markup in the typical case. For example, let's say I have ASP.net code something like this  &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;form &lt;/span&gt;&lt;span style="color: red;"&gt;runat&lt;/span&gt;&lt;span style="color: blue;"&gt;="server"&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;asp:Repeater &lt;/span&gt;&lt;span style="color: red;"&gt;ID&lt;/span&gt;&lt;span style="color: blue;"&gt;="rptCards"&lt;/span&gt;&lt;span style="color: red;"&gt; runat&lt;/span&gt;&lt;span style="color: blue;"&gt;="Server"&lt;/span&gt;&lt;span style="color: red;"&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;span style="color: black;"&gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;ItemTemplate&lt;/span&gt;&amp;gt;&lt;code&gt;&lt;span style="color: blue;"&gt;&lt;br /&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;asp:Image &lt;/span&gt;&lt;span style="color: red;"&gt;ID&lt;/span&gt;&lt;span style="color: blue;"&gt;="CardFace"&lt;/span&gt;&lt;span style="color: red;"&gt; runat&lt;/span&gt;&lt;span style="color: blue;"&gt;="server"&lt;/span&gt;&lt;span style="color: red;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;br &lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;asp:Label &lt;/span&gt;&lt;span style="color: red;"&gt;ID&lt;/span&gt;&lt;span style="color: blue;"&gt;="CardName"&lt;/span&gt;&lt;span style="color: red;"&gt; runat&lt;/span&gt;&lt;span style="color: blue;"&gt;="server"&lt;/span&gt;&lt;span style="color: red;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;br &lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;ItemTemplate&lt;/span&gt;&amp;gt;&lt;code&gt;&lt;span style="color: blue;"&gt;&lt;br /&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;asp:Repeater&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;/span&gt;&lt;/code&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;form&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;And then I data bind a playing card to my repeater in the code behind file, which ASP.net proceeds to render it as this…&lt;br /&gt;
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;form &lt;/span&gt;&lt;span style="color: red;"&gt;name&lt;/span&gt;&lt;span style="color: blue;"&gt;="ctl00"&lt;/span&gt;&lt;span style="color: red;"&gt; method&lt;/span&gt;&lt;span style="color: blue;"&gt;="post"&lt;/span&gt;&lt;span style="color: red;"&gt; action&lt;/span&gt;&lt;span style="color: blue;"&gt;="form.aspx"&lt;/span&gt;&lt;span style="color: red;"&gt; id&lt;/span&gt;&lt;span style="color: blue;"&gt;="ctl00"&amp;gt;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;div&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;&lt;br /&gt; &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;input &lt;/span&gt;&lt;span style="color: red;"&gt;type&lt;/span&gt;&lt;span style="color: blue;"&gt;="hidden"&lt;/span&gt;&lt;span style="color: red;"&gt; name&lt;/span&gt;&lt;span style="color: blue;"&gt;="__VIEWSTATE"&lt;/span&gt;&lt;span style="color: red;"&gt; id&lt;/span&gt;&lt;span style="color: blue;"&gt;="__VIEWSTATE"&lt;/span&gt;&lt;span style="color: red;"&gt; 					&lt;br /&gt; value&lt;/span&gt;&lt;span style="color: blue;"&gt;="/wEPDwULLTEyODIyNzUwMDAPZBYCAgEPZBYCAgEPFgIeC18hSXRlbUNvdW50AgEWAmYPZBYEAgEPDxY&lt;br /&gt; CHghJbWFnZVVybAUTL2NhcmRzLmFzcHg/Y2FyZD00NmRkAgMPDxYCHgRUZXh0BQ9RdWVlbiBvZiBIZWFydHNkZ&lt;br /&gt; GQAQrEoOi46tPS8NZ9nekUDim2+Mg=="&lt;/span&gt;&lt;span style="color: red;"&gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;/span&gt;&lt;/code&gt; &lt;code&gt;&lt;span style="color: black;"&gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;&lt;br /&gt; &amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;div&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;br /&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;img &lt;/span&gt;&lt;span style="color: red;"&gt;id&lt;/span&gt;&lt;span style="color: blue;"&gt;="rptCards_ctl00_CardFace"&lt;/span&gt;&lt;span style="color: red;"&gt; src&lt;/span&gt;&lt;span style="color: blue;"&gt;="/cards.aspx?card=46"&lt;/span&gt;&lt;span style="color: red;"&gt; style&lt;/span&gt;&lt;span style="color: blue;"&gt;="border-width:0px;"&lt;/span&gt;&lt;span style="color: red;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;br &lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&lt;br /&gt; &lt;/span&gt;&lt;span style="color: black;"&gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;span &lt;/span&gt;&lt;span style="color: red;"&gt;id&lt;/span&gt;&lt;span style="color: blue;"&gt;="rptCards_ctl00_CardName"&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;Queen of Hearts&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;span&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;br &lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;&lt;br /&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;form&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;What's with the &amp;lt;div&amp;gt; surrounding the &lt;span style="color: blue; font-family: Courier New; font-size: 10pt;"&gt;__VIEWSTATE&lt;/span&gt; control? Where did that &lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt;style&lt;/span&gt;&lt;span style="color: blue;"&gt;="border-width:0px;"&lt;/span&gt;&lt;/span&gt;&lt;span style="color: red;"&gt; 		&lt;/span&gt;come from? Why is there so much damn view state? Why do my Image and Label controls render IDs on the client? And why is it named &lt;span style="color: blue;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;rptCards_ctl00_CardFace&lt;/span&gt; 		&lt;/span&gt;instead of something shorter, such as &lt;span style="color: blue; font-family: Courier New; font-size: 10pt;"&gt;rptCards_0_CardFace&lt;/span&gt;?  &lt;/p&gt;
&lt;p&gt;Sometimes I have nested repeaters, sometimes I don't. Sometimes I use HTML controls instead of Web Controls, but the issue is the same. The elements in question aren't getting changed on the client and only get changed on the server during the initial HTTP GET during data binding. Normally, the &lt;span style="color: blue; font-family: Courier New; font-size: 10pt;"&gt;__VIEWSTATE&lt;/span&gt; just grows &amp;amp; grows as I add more stuff to the page. OK, you can avoid this by a few well placed &lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt;EnableViewState&lt;/span&gt;&lt;span style="color: blue;"&gt;="false"&lt;/span&gt;&lt;/span&gt; or disabling it altogether in web.config. Unfortunately, I don't always know when you really need it, so often times I end up disabling it on a control by control basis in a trial and error fashion, until my app works and my markup is small. Unless you &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/ViewState.asp"&gt;truly understand viewstate&lt;/a&gt;, you could end up meeting a fatal end with &lt;a href="http://weblogs.asp.net/infinitiesloop/archive/2006/08/03/Truly-Understanding-Viewstate.aspx"&gt;ViewState-ious of Borg&lt;/a&gt;. Fortunately, I understand that problem. &lt;/p&gt;
&lt;p&gt;What bothers me more is ID bloat, especially when you nest Repeaters, so an innocent looking &lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;asp:Hyperlink&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt; control ends up with an ID like...&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: blue; font-family: Courier New; font-size: 10pt;"&gt;rptMerchants_ctl01_rptShippingMethods_ctl00_rptLineItems_ctl00_ProductName&lt;/span&gt;, &lt;br /&gt;
&lt;br /&gt;
That's ugly, so I end up using shorter IDs for Repeaters. Unfortunately, that's not good enough at times, so I usually end up replacing many of my server controls with &lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;asp:Literal&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt; controls and controlling my markup directly. Unfortunately, doing that stops you from using the server control you really wanted to use, and makes complex page development a huge pain. &lt;/p&gt;
&lt;p&gt;Ideally, what I'd like is a &lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt;RenderClientIDs&lt;/span&gt;&lt;span style="color: blue;"&gt;="false"&lt;/span&gt;&lt;/span&gt; attribute for all ASP.net server controls. After all, the ID isn't sent to the server on the postback (just name / value pairs from form controls). You really only need it on the client if you are doing client side DOM/DHTML manipulation. I know you need a Control ID as a parameter to &lt;span style="color: maroon; font-family: Courier New; font-size: 10pt;"&gt;__doPostBack&lt;/span&gt;, but I usually don't need it on the client side HTML markup. It also seems odd that ASP.net is missing a &lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt;RenderClientIDs&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;/span&gt;attribute since they did have the foresight to create an &lt;span style="color: red; font-family: Courier New; font-size: 10pt;"&gt;EnableViewState&lt;/span&gt; attribute on server controls.&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;Most of the time, a Hyperlink control is just an &amp;lt;a&amp;gt; HTML tag, a Label control is just a &amp;lt;span&amp;gt; HTML tag, and an Image control is just an &amp;lt;img&amp;gt; HTML tag, so the ID attribute is just byte bloat running up my bandwidth bill. Why is it so hard to just get this instead?&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;img &lt;/span&gt;&lt;span style="color: red;"&gt;src&lt;/span&gt;&lt;span style="color: blue;"&gt;="/cards.aspx?card=46"&lt;/span&gt;&lt;span style="color: red;"&gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;br &lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;span&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;Queen of Hearts&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;span&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;br &lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: Arial,Verdana,Sans-Serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Is there a diet control library I don't know about or some magic web.config setting to stop unneeded ClientIDs from rendering? How does one fight ClientID bloat? Should I just wait for an &lt;a href="http://www.infoq.com/news/2007/12/MVC-vs-Web-Forms"&gt;MVC version of ASP.net&lt;/a&gt;? I'm kind of lukewarm on the whole MVC thing because of ignorance and the lingering bad taste of classic ASP. I don't mind paying the ASP.net tax, when it adds more value than byte bloat. It just annoys me, that I have resort to &lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;asp:Literal&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt; controls to avoid paying the ASP.net tax in some cases. &lt;/p&gt;
&lt;p&gt;So what are the downsides of MVC ASP.net vs Classic ASP.net? Will my &lt;a href="http://www.componentart.com/"&gt;favorite 3rd party ASP.net web control product&lt;/a&gt; work on it? Do I just need to read &lt;a href="http://haacked.com/archive/2007/12/13/thank-you-for-helping-me-with-my-job-with-asp.net.aspx"&gt;Phil Haack's blog&lt;/a&gt; and &lt;a href="http://www.hanselman.com/blog/January2008PADNUGMeetingShouldYouFearMVCForASPNET.aspx"&gt;Scott Hanselman's blog&lt;/a&gt; more often? Any idea when an &lt;a href="http://msdnevents.com/"&gt;MSDN event&lt;/a&gt; will cover MVC ASP.net? Oh well, it beats tracking down memory or COM interface leaks in an ISAPI application for a living.&lt;/p&gt;&lt;img src="http://blog.caffeinatedsoftware.com/aggbug/31.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>&lt;i&gt;&lt;b&gt;Caffeinated&lt;/b&gt;&lt;/i&gt; Software</dc:creator>
            <guid>http://blog.caffeinatedsoftware.com/archive/2008/01/11/best-asp.net-interview-question-ever-part-1.aspx</guid>
            <pubDate>Sat, 12 Jan 2008 07:56:42 GMT</pubDate>
            <wfw:comment>http://blog.caffeinatedsoftware.com/comments/31.aspx</wfw:comment>
            <comments>http://blog.caffeinatedsoftware.com/archive/2008/01/11/best-asp.net-interview-question-ever-part-1.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://blog.caffeinatedsoftware.com/comments/commentRss/31.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Toy with Sploggers w/ Dynamic Images  </title>
            <link>http://blog.caffeinatedsoftware.com/archive/2007/05/12/Toy-with-Sploggers-w-Dynamic-Images.aspx</link>
            <description>&lt;p&gt;Over at my &lt;a href="http://www.raincityguide.com/2007/05/11/steel-this-blog-post-friday-fun-with-splog-busters/"&gt;second home&lt;/a&gt;, I talked about how to annoy sploggers w/ a dynamic image. A dynamic image is merely any image generated programmatically at request time. So with a dynamic image, you have total control of the content that will get displayed when the url gets requested. &lt;/p&gt;
&lt;p style="background: white none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;Typically, when a splogger copies a blog post, they often times leave all the original hyperlinks and images links intact. Sploggers are lazy folks. If they are too lazy to write their own blog post, they are usually too lazy to edit yours. So if they do hotlink to an image on your server, they are now dependent on your server to serve that image request. And this is why we can change the image out from underneath them and have fun with them. &lt;/p&gt;
&lt;p style="background: white none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;If you're interested in more background on this sort of thing, I'd recommend you check out &lt;a href="http://www.hanselman.com/blog/ABoilerplateHttpHandler.aspx"&gt;Scot Hanselman's Computer Zen&lt;/a&gt; blog post on HttpHandlers. Anyway, here's how my variation worked… &lt;/p&gt;
&lt;p style="background: white none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;This first thing I did is write code to generate a text warning message… Nearly all modern web development frameworks have the ability to generate images on the fly, and put the generated bitmap on the request's response stream. So here's some C# code that draws some text in a solid colored rectangle. &lt;/p&gt;
&lt;div style="background: white none repeat scroll 0%; font-size: 10pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; color: black; font-family: Courier New;"&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Bitmap&lt;/span&gt; GetSploggerWarning(&lt;span style="color: blue;"&gt;string&lt;/span&gt; text)&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;{&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: green;"&gt;// Create the objects we need for drawing&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: rgb(43, 145, 175);"&gt;Bitmap&lt;/span&gt; bmp = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Bitmap&lt;/span&gt;(350, 200);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: rgb(43, 145, 175);"&gt;Graphics&lt;/span&gt; gr = System.Drawing.&lt;span style="color: rgb(43, 145, 175);"&gt;Graphics&lt;/span&gt;.FromImage(bmp);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: green;"&gt;// Create our background colored rectangle&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: rgb(43, 145, 175);"&gt;SolidBrush&lt;/span&gt; fill = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;SolidBrush&lt;/span&gt;(&lt;span style="color: rgb(43, 145, 175);"&gt;Color&lt;/span&gt;.Purple);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: rgb(43, 145, 175);"&gt;Rectangle&lt;/span&gt; rect = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Rectangle&lt;/span&gt;(0, 0, 350, 200);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    gr.FillRectangle(fill, rect);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: green;"&gt;// Draw our text so it's big, centered &amp;amp; anti-aliased&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: rgb(43, 145, 175);"&gt;Font&lt;/span&gt; font = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Font&lt;/span&gt;(&lt;span style="color: rgb(163, 21, 21);"&gt;"Arial"&lt;/span&gt;, 24, &lt;span style="color: rgb(43, 145, 175);"&gt;GraphicsUnit&lt;/span&gt;.Pixel);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: rgb(43, 145, 175);"&gt;SolidBrush&lt;/span&gt; textbrush = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;SolidBrush&lt;/span&gt;(&lt;span style="color: rgb(43, 145, 175);"&gt;Color&lt;/span&gt;.White);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    gr.TextRenderingHint = &lt;span style="color: rgb(43, 145, 175);"&gt;TextRenderingHint&lt;/span&gt;.AntiAlias;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: rgb(43, 145, 175);"&gt;StringFormat&lt;/span&gt; stringFormat = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;StringFormat&lt;/span&gt;();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    stringFormat.Alignment = &lt;span style="color: rgb(43, 145, 175);"&gt;StringAlignment&lt;/span&gt;.Center;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    stringFormat.LineAlignment = &lt;span style="color: rgb(43, 145, 175);"&gt;StringAlignment&lt;/span&gt;.Center;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    gr.DrawString(text, font, textbrush, rect, stringFormat);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: green;"&gt;// Clean up our mess and return the image&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    gr.Dispose();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: blue;"&gt;return&lt;/span&gt; bmp;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;}&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;&lt;!--EndFragment--&gt;OK, now that we have the images we want to use, we need to write code which will generate a different image depending on the circumstance. So, what I did is look at the &lt;a href="http://us.php.net/reserved.variables"&gt;HTTP_REFERER header&lt;/a&gt; from the current request. If a web browser requests an image from a web page, it will usually place the url of the page which is requesting the image in the HTTP_REFERER header. However if a web browser requests the image directly you may not get that header in the request. Also, I've read that &lt;a href="http://www.thescripts.com/forum/thread335224.html"&gt;Norton Internet Security&lt;/a&gt; strips out the header and I'm sure proxy servers that muck with the headers too. In short, you can't count on that header being there. &lt;/p&gt;
&lt;p&gt;Also, it's important to note that the value in this header can't be trusted. If the image is being requested by web browser there's a good chance it'll have the value you expect. However, there's nothing preventing a hacker from creating an HTTP request that is identical to the one a page from your domain would create. So, it's is really only effective if they retrieve the image from a sploggers web page. &lt;/p&gt;
&lt;div style="background: white none repeat scroll 0%; font-size: 10pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; color: black; font-family: Courier New;"&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; ProcessRequest(&lt;span style="color: rgb(43, 145, 175);"&gt;HttpContext&lt;/span&gt; context)&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;{&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: rgb(43, 145, 175);"&gt;HttpRequest&lt;/span&gt; Request = context.Request;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: rgb(43, 145, 175);"&gt;HttpResponse&lt;/span&gt; Response = context.Response;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: rgb(43, 145, 175);"&gt;Bitmap&lt;/span&gt; bmp;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: blue;"&gt;string&lt;/span&gt; message = &lt;span style="color: rgb(43, 145, 175);"&gt;String&lt;/span&gt;.Empty;       &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: blue;"&gt;string&lt;/span&gt; hostingdomain = &lt;span style="color: rgb(163, 21, 21);"&gt;"raincityguide.com"&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: blue;"&gt;if&lt;/span&gt; (Request.UrlReferrer == &lt;span style="color: blue;"&gt;null&lt;/span&gt;)&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: green;"&gt;// Handle the case of the image not being on a web page&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        bmp = GetSploggerWarning(&lt;span style="color: rgb(163, 21, 21);"&gt;"Don't SPLOG!\n Fight SPLOG!"&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: blue;"&gt;else&lt;/span&gt; &lt;span style="color: blue;"&gt;if&lt;/span&gt; (!Request.UrlReferrer.Host.EndsWith(hostingdomain))&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: green;"&gt;// Handle the case of another domain's page, using my image&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        message = &lt;span style="color: rgb(43, 145, 175);"&gt;String&lt;/span&gt;.Format(&lt;span style="color: rgb(163, 21, 21);"&gt;"{0} is a SPLOG! Please visit {1}."&lt;/span&gt;,&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            Request.UrlReferrer.Host,&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            hostingdomain);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        bmp = GetSploggerWarning(message);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: blue;"&gt;else&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: green;"&gt;// Handle the case my domain's page, using my image&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        message = &lt;span style="color: rgb(43, 145, 175);"&gt;String&lt;/span&gt;.Format(&lt;span style="color: rgb(163, 21, 21);"&gt;"This image was paid for by {0} "&lt;/span&gt; +&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(163, 21, 21);"&gt;"and I approve of its hosting."&lt;/span&gt;,            &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            hostingdomain);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        bmp = GetSploggerWarning(message);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    }&lt;br /&gt;
&lt;span style="font-size: 10pt; font-family: Courier New;"&gt;&lt;span style="color: green;"&gt;    // To be continued… &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;OK, now that we got our image, we gotta send it across the wire. The only tricky part is that we have to tell the browser not to cache the image, since otherwise; the browser will reuse the image regardless of the domain it's being hosted on. So if somebody visits your blog and then the splog, it's likely the browser would display the same image in both places because the browser cached the original image, and re-uses it if somebody else refers to it. &lt;/p&gt;
&lt;div style="background: white none repeat scroll 0%; font-size: 10pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; color: black; font-family: Courier New;"&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: green;"&gt;// Set the content type and return the image&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    Response.Clear();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    Response.ContentType = &lt;span style="color: rgb(163, 21, 21);"&gt;"image/png"&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: green;"&gt;// Check out &lt;a href="http://www.hanselman.com/blog/ABoilerplateHttpHandler.aspx" style="color: green; text-decoration: underline;"&gt;http://www.hanselman.com/blog/ABoilerplateHttpHandler.aspx&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    Response.Cache.SetExpires(&lt;span style="color: rgb(43, 145, 175);"&gt;DateTime&lt;/span&gt;.MinValue);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    Response.Cache.SetNoStore();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    Response.Cache.SetCacheability(&lt;span style="color: rgb(43, 145, 175);"&gt;HttpCacheability&lt;/span&gt;.NoCache);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: green;"&gt;// To Save a bitmap as PNG, we need a seekable stream, otherwise we&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: green;"&gt;    // get a GDI exception. Visit &lt;a href="http://authors.aspalliance.com/chrisg/tools/view-png.vb.aspx" style="color: green;"&gt;Asp alliance&lt;/a&gt; for more details &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: rgb(43, 145, 175);"&gt;MemoryStream&lt;/span&gt; MemStream = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;MemoryStream&lt;/span&gt;();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    bmp.Save(MemStream, &lt;span style="color: rgb(43, 145, 175);"&gt;ImageFormat&lt;/span&gt;.Png);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    MemStream.WriteTo(Response.OutputStream);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: green;"&gt;// dispose of our objects&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    bmp.Dispose();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;}&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;&lt;!--EndFragment--&gt;Anyway, it's not an industrial strength approach but it's enough to stop the causal splogger from stealing content again. For an industrial strength solution, you'd have to combine this approach with IP black/white and IP geo-location and other tricks that products like &lt;a href="http://www.port80software.com/products/linkdeny/"&gt;Port 80 software's LinkDeny&lt;/a&gt; employ. &lt;/p&gt;
&lt;p&gt;And if &lt;a href="http://www.haacked.com/"&gt;Mr. Haack reads&lt;/a&gt; this and gets around to creating a world class plug-in model for &lt;a href="http://subtextproject.com/"&gt;SubText&lt;/a&gt;, I'd be happy to contribute a basic anti-leach / anti-splog plug-in for it. It's not fair that the WordPress kids have all the fun.&lt;/p&gt;&lt;img src="http://blog.caffeinatedsoftware.com/aggbug/24.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>&lt;i&gt;&lt;b&gt;Caffeinated&lt;/b&gt;&lt;/i&gt; Software</dc:creator>
            <guid>http://blog.caffeinatedsoftware.com/archive/2007/05/12/Toy-with-Sploggers-w-Dynamic-Images.aspx</guid>
            <pubDate>Sat, 12 May 2007 16:15:59 GMT</pubDate>
            <wfw:comment>http://blog.caffeinatedsoftware.com/comments/24.aspx</wfw:comment>
            <comments>http://blog.caffeinatedsoftware.com/archive/2007/05/12/Toy-with-Sploggers-w-Dynamic-Images.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://blog.caffeinatedsoftware.com/comments/commentRss/24.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Is there a better way to compute a Median in SQL?</title>
            <link>http://blog.caffeinatedsoftware.com/archive/2007/05/01/Is-there-a-better-way-to-compute-a-Median.aspx</link>
            <description>I'm currently playing with random ideas I have for Nimitz (aka the next version of my NWMLS search tool), and one of the things I'm thinking about is displaying the Median value of properties that match an arbitrary search criteria. I already do something similar to this now on &lt;a href="http://www.raincityguide.com/2006/04/25/rcgs-zearch-is-released/"&gt;Zearch &lt;/a&gt;(the current version of my NWMLS search tool). with MIN, MAX, and AVG. So I wrote a Stored Proc (using MS SQL 2005 features), and came up with the following. (FYI - I was inspired by &lt;a href="http://pluralsight.com/blogs/dan/archive/2005/09/29/15082.aspx"&gt;this blog post&lt;/a&gt;).&lt;br /&gt;
&lt;br /&gt;
&lt;div class="csharpcode"&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;CREATE&lt;/span&gt;  &lt;span class="kwrd"&gt;PROC&lt;/span&gt; [dbo].[GetMedian]&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;(&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;    @Col &lt;span class="kwrd"&gt;varchar&lt;/span&gt;(100),&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;    @&lt;span class="kwrd"&gt;Table&lt;/span&gt; &lt;span class="kwrd"&gt;varchar&lt;/span&gt;(100),&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;    @SqlWhere  &lt;span class="kwrd"&gt;varchar&lt;/span&gt;(1000)&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;)&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;&lt;span class="kwrd"&gt;AS&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;&lt;span class="kwrd"&gt;BEGIN&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt; &lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;    &lt;span class="kwrd"&gt;DECLARE&lt;/span&gt; @&lt;span class="kwrd"&gt;Count&lt;/span&gt; &lt;span class="kwrd"&gt;AS&lt;/span&gt; &lt;span class="kwrd"&gt;INT&lt;/span&gt;, @MiddleRow &lt;span class="kwrd"&gt;AS&lt;/span&gt; &lt;span class="kwrd"&gt;INT&lt;/span&gt;, @Median &lt;span class="kwrd"&gt;AS&lt;/span&gt; &lt;span class="kwrd"&gt;INT&lt;/span&gt; &lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;    &lt;span class="kwrd"&gt;DECLARE&lt;/span&gt; @SqlAll nvarchar(&lt;span class="kwrd"&gt;MAX&lt;/span&gt;)&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt; &lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;    &lt;span class="kwrd"&gt;SET&lt;/span&gt; @SqlAll = &lt;span class="str"&gt;'WITH MLSSTATS AS '&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;    &lt;span class="kwrd"&gt;SET&lt;/span&gt; @SqlAll = @SqlAll + &lt;span class="str"&gt;'('&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;    &lt;span class="kwrd"&gt;SET&lt;/span&gt; @SqlAll = @SqlAll + &lt;span class="str"&gt;'SELECT ROW_NUMBER() OVER (ORDER BY '&lt;/span&gt; + @Col&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;    &lt;span class="kwrd"&gt;SET&lt;/span&gt; @SqlAll = @SqlAll + &lt;span class="str"&gt;' DESC ) AS RowNum , '&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;    &lt;span class="kwrd"&gt;SET&lt;/span&gt; @SqlAll = @SqlAll + &lt;span class="str"&gt;'(SELECT COUNT(*) FROM '&lt;/span&gt; +@&lt;span class="kwrd"&gt;Table&lt;/span&gt; + &lt;span class="str"&gt;' '&lt;/span&gt; &lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;    &lt;span class="kwrd"&gt;SET&lt;/span&gt; @SqlAll = @SqlAll + @SqlWhere + &lt;span class="str"&gt;') As Cnt,'&lt;/span&gt; &lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  19:  &lt;/span&gt;    &lt;span class="kwrd"&gt;SET&lt;/span&gt; @SqlAll = @SqlAll + @Col&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  20:  &lt;/span&gt;    &lt;span class="kwrd"&gt;SET&lt;/span&gt; @SqlAll = @SqlAll + &lt;span class="str"&gt;' FROM '&lt;/span&gt; + @&lt;span class="kwrd"&gt;Table&lt;/span&gt; + &lt;span class="str"&gt;' '&lt;/span&gt; + @SqlWhere &lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  21:  &lt;/span&gt;    &lt;span class="kwrd"&gt;SET&lt;/span&gt; @SqlAll = @SqlAll + &lt;span class="str"&gt;') '&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  22:  &lt;/span&gt;    &lt;span class="kwrd"&gt;SET&lt;/span&gt; @SqlAll = @SqlAll + &lt;span class="str"&gt;'select AVG('&lt;/span&gt; + @Col +&lt;span class="str"&gt;') from MLSSTATS '&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  23:  &lt;/span&gt;    &lt;span class="kwrd"&gt;SET&lt;/span&gt; @SqlAll = @SqlAll + &lt;span class="str"&gt;'where rownum  IN((Cnt + 1) / 2, (Cnt + 2) / 2)'&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  24:  &lt;/span&gt; &lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  25:  &lt;/span&gt;    &lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  26:  &lt;/span&gt;    &lt;span class="kwrd"&gt;EXEC&lt;/span&gt; sp_executesql @SqlAll &lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  27:  &lt;/span&gt;END&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;So if, let's say, I wanted to find the median value of all the houses currently listed in the city of Redmond, I'd do something like this...&lt;br /&gt;
&lt;/p&gt;
&lt;div class="csharpcode"&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;GetMedian &lt;span class="str"&gt;'ListPrice'&lt;/span&gt;, &lt;span class="str"&gt;'MLSTABLE'&lt;/span&gt;, &lt;span class="str"&gt;'WHERE City in ('&lt;/span&gt;&lt;span class="str"&gt;'Redmond'&lt;/span&gt;&lt;span class="str"&gt;')'&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;And then the proc would do it's dynamic SQL black magic and end up executing this...&lt;/p&gt;
&lt;div class="csharpcode"&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;WITH&lt;/span&gt; MLSSTATS &lt;span class="kwrd"&gt;AS&lt;/span&gt; &lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;(&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; ROW_NUMBER() &lt;span class="kwrd"&gt;OVER&lt;/span&gt; (&lt;span class="kwrd"&gt;ORDER&lt;/span&gt; &lt;span class="kwrd"&gt;BY&lt;/span&gt; ListPrice &lt;span class="kwrd"&gt;DESC&lt;/span&gt; ) &lt;span class="kwrd"&gt;AS&lt;/span&gt; RowNum , &lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;(&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; &lt;span class="kwrd"&gt;COUNT&lt;/span&gt;(*) &lt;span class="kwrd"&gt;FROM&lt;/span&gt; MLSTABLE &lt;span class="kwrd"&gt;WHERE&lt;/span&gt; City &lt;span class="kwrd"&gt;in&lt;/span&gt; (&lt;span class="str"&gt;'Redmond'&lt;/span&gt;)) &lt;span class="kwrd"&gt;As&lt;/span&gt; Cnt,&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;ListPrice &lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;&lt;span class="kwrd"&gt;FROM&lt;/span&gt; MLSTABLE&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;&lt;span class="kwrd"&gt;WHERE&lt;/span&gt; City &lt;span class="kwrd"&gt;in&lt;/span&gt; (&lt;span class="str"&gt;'Redmond'&lt;/span&gt;)&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;)&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;&lt;span class="kwrd"&gt;select&lt;/span&gt; &lt;span class="kwrd"&gt;AVG&lt;/span&gt;(ListPrice)&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;&lt;span class="kwrd"&gt;from&lt;/span&gt; MLSSTATS &lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;&lt;span class="kwrd"&gt;where&lt;/span&gt; rownum  &lt;span class="kwrd"&gt;IN&lt;/span&gt;((Cnt + 1) / 2, (Cnt + 2) / 2)&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;&lt;br /&gt;
The SQL is ugly, but that's that nature of the beast. Anyway, the problem is that I really want do to this...&lt;/p&gt;
&lt;div class="csharpcode"&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; &lt;span class="kwrd"&gt;AVG&lt;/span&gt;(listprice), MEDIAN(&lt;span class="str"&gt;'ListPrice'&lt;/span&gt;, &lt;span class="str"&gt;'MLSTABLE'&lt;/span&gt;, &lt;span class="str"&gt;'WHERE City = '&lt;/span&gt;&lt;span class="str"&gt;'Redmond'&lt;/span&gt;&lt;span class="str"&gt;''&lt;/span&gt;)&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;&lt;span class="kwrd"&gt;FROM&lt;/span&gt; MLSTABLE&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;&lt;span class="kwrd"&gt;WHERE&lt;/span&gt; City = &lt;span class="str"&gt;'Redmond'&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;&lt;br /&gt;
Or better yet, try to implement Median as a user defined aggregate function in C# / CLR language so it's even easier to use like so...&lt;/p&gt;
&lt;div class="csharpcode"&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; &lt;span class="kwrd"&gt;AVG&lt;/span&gt;(listprice), MEDIAN(ListPrice)&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;&lt;span class="kwrd"&gt;FROM&lt;/span&gt; MLSTABLE&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;&lt;span class="kwrd"&gt;WHERE&lt;/span&gt; City = &lt;span class="str"&gt;'Redmond'&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;&lt;br /&gt;
According the above blog post it can't be done in a CLR language (which I don't understand). I guess user defined aggregates written in a CLR language only get the values of a set one at a time, instead of the entire set (which you would obviously need to compute a median)? Either way, I'm wondering if there's a way to convert my ugly proc into an ugly function instead? I think what's tripping me up, is that I need to define a variable that's accessible from dynamic SQL and returnable from the function that calls it.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;&lt;img src="http://blog.caffeinatedsoftware.com/aggbug/20.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>&lt;i&gt;&lt;b&gt;Caffeinated&lt;/b&gt;&lt;/i&gt; Software</dc:creator>
            <guid>http://blog.caffeinatedsoftware.com/archive/2007/05/01/Is-there-a-better-way-to-compute-a-Median.aspx</guid>
            <pubDate>Tue, 01 May 2007 15:38:58 GMT</pubDate>
            <wfw:comment>http://blog.caffeinatedsoftware.com/comments/20.aspx</wfw:comment>
            <comments>http://blog.caffeinatedsoftware.com/archive/2007/05/01/Is-there-a-better-way-to-compute-a-Median.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://blog.caffeinatedsoftware.com/comments/commentRss/20.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>